Flip Reference

Map::iterator Class Reference

Declared in

flip/Map.h

template <class T> class Map
{
class iterator;
class const_iterator;
class reverse_iterator;
class const_reverse_iterator;
};

Map::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

key

Returns the key associated to the iterator.

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

key

const KeyBlob & key () const;

Returns the key associated to the iterator.

Example :

void  add (Map <Parameter> & parameters)
{
   auto it = parameters.emplace ("some_name");
   auto serialized_key = it.key ().get ();
   std::string name (serialized_key.begin (), serialized_key.end ());
   // name is "some_name"
}

added

bool added () const;

Returns true iff the iterator was added to the container.

Example :

void  Observer::document_changed (Map <Parameter> & parameters)
{
   auto it = parameters ();
   auto it_end = parameters ();
   for (; it != it_end ; ++it)
   {
      Parameter & parameter = *it;
      if (it.added ())
      {
         // the parameter was added
      }
      if (it.removed ())
      {
         // the parameter was removed
      }
   }
}

removed

bool removed () const;

Returns true iff the iterator was removed to the container.

Example :

void  Observer::document_changed (Map <Parameter> & parameters)
{
   auto it = parameters ();
   auto it_end = parameters ();
   for (; it != it_end ; ++it)
   {
      Parameter & parameter = *it;
      if (it.added ())
      {
         // the parameter was added
      }
      if (it.removed ())
      {
         // the parameter was removed
      }
   }
}

resident

bool resident () const;

Returns true iff the iterator was neither added or removed.