Flip Reference

Array::iterator Class Reference

Declared in

flip/Array.h

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

T

The type of the elements. T must inherit from flip::Object

Member Types

value_type

T

reference

T &

pointer

T *

difference_type

std::ptrdiff_t

iterator_category

std::bidirectional_iterator_tag

Member Functions Synopsys

Miscellaneous

added

Returns true iff the iterator was added to the container.

removed

Returns true iff the iterator was removed to the container.

resident

Returns true iff the iterator was neither added or removed.

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.