Array::iterator Class Reference
Declared in |
|
template <class T> class Array |
{ |
class iterator; |
class const_iterator; |
class reverse_iterator; |
class const_reverse_iterator; |
}; |
Array::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 in the container, then the destination iterator is considered as added while the object is considered as resident.
Example :
void Observer::document_changed (Array <Track> & tracks) |
{ |
auto it = tracks.begin (); |
auto it_end = tracks.end (); |
for (; it != it_end ; ++it) |
{ |
Track & track = *it; |
if (it.added () && track.resident ()) |
{ |
// the track was moved in the container |
// this is the destination position |
} |
if (it.removed () && track.resident ()) |
{ |
// the track was moved in the container |
// this is the source position |
} |
} |
} |
removed
bool removed () const; |
Returns true
iff the iterator was removed to the container.
Note: When an object is moved in the container, then the source iterator is considered as removed while the object is considered as resident.
Example :
void Observer::document_changed (Array <Track> & tracks) |
{ |
auto it = tracks.begin (); |
auto it_end = tracks.end (); |
for (; it != it_end ; ++it) |
{ |
Track & track = *it; |
if (it.added () && track.resident ()) |
{ |
// the track was moved in the container |
// this is the destination position |
} |
if (it.removed () && track.resident ()) |
{ |
// the track was moved in the container |
// this is the source position |
} |
} |
} |
resident
bool resident () const; |
Returns true
iff the iterator was neither added or removed.