This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FedeListIterator.h
164 lines (134 loc) · 5.58 KB
/
FedeListIterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* File: FedeListIterator.h
* Author: Federico Bertani
*
* Created on 13 gennaio 2016, 21.49
*/
#ifndef FEDELISTITERATOR_H
#define FEDELISTITERATOR_H
#include <iterator>
#include "Node.hpp"
/**
* An iterator through a Fedelist. <br>
* It's point to a FedeList node element and has the ability to iterate through them.
*/
template<class ListType>
class FedeListIterator {
public:
/**
* Create an iterator that points to nothing
*/
FedeListIterator();
/**
* Create a interator thats points to a node
* @param node Node<ListType*>* : the node to point to.
*/
FedeListIterator(Node<ListType> *node, int position);
/**
* Clone an existing iterator
* @param orig FedeListIterator&: the iterator to clone.
*/
FedeListIterator(const FedeListIterator &orig);
/**
* Destroy an interator.
*/
virtual ~FedeListIterator();
/**
* Override assignemnt operator.
* @param right FedeListIterator<ListType*>& : the object to assign.
* @return FedeListIterator<ListType*>*: the object assigned
*/
FedeListIterator<ListType> &operator=(const FedeListIterator<ListType> &right);
/**
* Ovverride direct access operator.This browse the list until the given position is found.
* @param position int: the position to get .
* @return FedeListIterator<ListType*>* : a pointer to the element searched
*/
FedeListIterator<ListType> &operator[](const int position);
/**
* Get the node pointed by the iterator.
* @return FedeListIterator<ListType*>*: the node pointed by the iterator.
*/
Node<ListType> *operator*();
/**
* Access the node pointed by the iterator.
* @return FedeListIterator<ListType*>*: the node pointed by the iterator.
*/
Node<ListType> *operator->();
/**
* Compare two Iterators, if they point to the same node they are the same iterator.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool: true if the iterators are the same, false otherwise.
*/
bool operator==(const FedeListIterator<ListType> &right);
/**
* Compare two iterator, if they point to different nodes they are different iterators.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool:true if the iterator are the same, false otherwise..
*/
bool operator!=(const FedeListIterator<ListType> &right);
/**
* Compare two iterators and check if an iterator is pointing at a node that is behind onother.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool: true if the iterator is smaller, false otherwise.
*/
bool operator<(const FedeListIterator<ListType> &right);
/**
* Compare two iterators and check if an iterator is pointing at a node that is behind onother or the same.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool: true if the iterator is smaller or equal, false otherwise.
*/
bool operator<=(const FedeListIterator<ListType> &right);
/**
* Compare two iterators and check if an iterator is pointing at a node that is ahead onother.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool: true if the iterator is greater, false otherwise.
*/
bool operator>(const FedeListIterator<ListType> &right);
/**
* Compare two iterators and check if an iterator is pointing at a node that is ahead onother or they are the same.
* @param right FedeListIterator<ListType*>*: the iterator to compare
* @return bool: true if the iterator is greater or equal false otherwise.
*/
bool operator>=(const FedeListIterator<ListType> &right);
/**
* Create a new iterator that point to the position in the list that is the sum of the position of two others iterators.
* @param right FedeListIterator<ListType*>*: the iterator to sum
* @return FedeListIterator<ListType*>*: the new iterator.
*/
FedeListIterator<ListType> operator+(const FedeListIterator<ListType> &right);
/**
* Create a new iterator that point to the position in the list that is the difference of the position of two other iterators.
* @param right FedeListIterator<ListType*>*: the iterator to subtract
* @return FedeListIterator<ListType*>*: the new iterator.
*/
FedeListIterator<ListType> operator-(const FedeListIterator<ListType> &right);
/**
* Advance the iterator to a position but return the old operator.
* @return FedeListIterator<ListType*>*: the old iterator.
*/
FedeListIterator<ListType> &operator++();
/**
* Advance the iterator to a position and return it.
* @return FedeListIterator<ListType*>*: the iterator increased.
*/
FedeListIterator<ListType> &operator++(int);
/**
* Decrease the iterator to a position but return the old iterator.
* @return FedeListIterator<ListType*>*: the old iterator.
*/
FedeListIterator<ListType> &operator--();
/**
* Decrese the iterator to a position and return it.
* @return FedeListIterator<ListType*>*: the iterator increased.
*/
FedeListIterator<ListType> &operator--(int);
void setNode(Node<ListType> *node, int position);
int getPosition() const;
void setPosition(int position);
private:
int position;
Node<ListType> *pointer;
};
#include "FedeListIterator.cpp"
#endif /* FEDELISTITERATOR_H */