IterableValueMap

Declared in lemon/maps.h, in the group Graph Maps; the same class on the Doxygen site.

template< typename GR , typename K , typename V >
class IterableValueMap : protected Type< GR , K >

Dynamic iterable map for comparable values.

This class provides a special graph map type which can store a comparable value for graph items (Node, Arc or Edge). For each value it is possible to iterate on the keys mapped to the value (ItemIt), and the values of the map can be accessed with an STL compatible forward iterator (ValueIt). The map stores a linked list for each value, which contains the items mapped to the value, and the used values are stored in balanced binary tree (std::map).

IterableBoolMap and IterableIntMap are similar classes specialized for bool and int values, respectively.

This type is not reference map, so it cannot be modified with the subscript operator.

See also

CrossRefMap

Template Parameters:
  • GR – The graph type.

  • K – The key type of the map (GR::Node, GR::Arc or GR::Edge).

  • V – The value type of the map. It can be any comparable value type.

Public Types

typedef ItemSetTraits< GR , K >::template Map< _maps_bits::IterableValueMapNode< K , V > >::Type Parent
typedef K Key

The key type.

typedef V Value

The value type.

typedef GR Graph

The graph type.

Public Functions

inline explicit IterableValueMap( const Graph & graph , const Value & value = Value() )

Constructor of the map with a given value.

inline ValueIt beginValue() const

Returns an iterator to the first value.

Returns an STL compatible iterator to the first value of the map. The values of the map can be accessed in the [beginValue, endValue) range.

inline ValueIt endValue() const

Returns an iterator after the last value.

Returns an STL compatible iterator after the last value of the map. The values of the map can be accessed in the [beginValue, endValue) range.

inline void set( const Key & key , const Value & value )

Set operation of the map.

inline const Value & operator[]( const Key & key ) const

Const subscript operator of the map.

inline LemonRangeWrapper2< ItemIt , IterableValueMap , V > items( const V & value )

STL style iterator for the keys with the same value.

This is an STL style wrapper for ItemIt. It can be used in range-based for loops, STL algorithms, etc.

Protected Functions

inline void unlace( const Key & key )
inline void lace( const Key & key )
inline virtual void add( const Key & key )
inline virtual void add( const std::vector< Key > & keys )
inline virtual void erase( const Key & key )
inline virtual void erase( const std::vector< Key > & keys )
inline virtual void build()
inline virtual void clear()
class ValueIt

Forward iterator for values.

This iterator is an STL compatible forward iterator on the values of the map. The values can be accessed in the [beginValue, endValue) range.

Public Types

typedef std::forward_iterator_tag iterator_category
typedef Value value_type
typedef std::ptrdiff_t difference_type
typedef Value * pointer
typedef Value & reference

Public Functions

inline ValueIt()

Constructor.

inline ValueIt & operator++()

inline ValueIt operator++(int)

inline const Value & operator*() const

inline const Value * operator->() const

inline bool operator==( ValueIt jt ) const

inline bool operator!=( ValueIt jt ) const

class ItemIt : public Key

Iterator for the keys with the same value. It works like a graph item iterator, it can be converted to the item type of the map, incremented with ++ operator, and if the iterator leaves the last valid item, it will be equal to INVALID.

Public Types

typedef Key Parent

Public Functions

inline ItemIt(Invalid)

Invalid constructor & conversion.

This constructor initializes the iterator to be invalid.

See also

Invalid for more details.

inline ItemIt( const IterableValueMap & map , const Value & value )

Creates an iterator with a value. It iterates on the keys which have the given value.

Parameters:
inline ItemIt & operator++()

Increment operator.

Increment Operator.