Collection::iterator Class Reference
Declared in |
|
template <class T> class Collection |
{ |
class iterator; |
class const_iterator; |
class reverse_iterator; |
class const_reverse_iterator; |
}; |
Collection::iterator satisfies the BidirectionalIterator C++ concept.
WARNING: Unlike the C++ standard library, when an element is erased from a container, and if iterating over the container before commit, the element is still present until the modification is commited, but the iterator is marked as removed.
Template Parameters
| The type of the elements. |
Member Types
|
|
|
|
|
|
|
|
|
|
Member Functions Synopsys
Miscellaneous
Returns | |
Returns | |
Returns |
Member Functions
added
bool added () const; |
Returns true iff the iterator was added to the container.
Note: When an object is moved between containers, then the destination iterator is considered as added while the object is considered as resident.
Example :
void Observer::document_changed (Collection <Note> & notes) |
{ |
auto it = notes.begin (); |
auto it_end = notes.end (); |
for (; it != it_end ; ++it) |
{ |
Note & note = *it; |
if (it.added () && note.resident ()) |
{ |
// the note was moved from one container to another |
// this is the destination container |
} |
if (it.removed () && note.resident ()) |
{ |
// the note was moved from one container to another |
// this is the source container |
} |
} |
} |
removed
bool removed () const; |
Returns true iff the iterator was removed to the container.
Note: When an object is moved between containers, then the source iterator is considered as removed while the object is considered as resident.
void Observer::document_changed (Collection <Note> & notes) |
{ |
auto it = notes.begin (); |
auto it_end = notes.end (); |
for (; it != it_end ; ++it) |
{ |
Note & note = *it; |
if (it.added () && note.resident ()) |
{ |
// the note was moved from one container to another |
// this is the destination container |
} |
if (it.removed () && note.resident ()) |
{ |
// the note was moved from one container to another |
// this is the source container |
} |
} |
} |
resident
bool resident () const; |
Returns true iff the iterator was neither added or removed.