IterableIntMap

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

template< typename GR , typename K >
class IterableIntMap : protected Type< GR , K >

Dynamic iterable integer map.

This class provides a special graph map type which can store an integer value for graph items (Node, Arc or Edge). For each non-negative value it is possible to iterate on the keys mapped to the value.

This map is intended to be used with small integer values, for which it is efficient, and supports iteration only for non-negative values. If you need large values and/or iteration for negative integers, consider to use IterableValueMap instead.

This type is a reference map, so it can be modified with the subscript operator.

See also

CrossRefMap

Note

The size of the data structure depends on the largest value in the map.

Template Parameters:
  • GR – The graph type.

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

Public Types

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

The key type.

typedef int Value

The value type.

typedef GR Graph

The graph type.

typedef True ReferenceMapTag

Indicates that the map is reference map.

typedef const Value & ConstReference

The const reference type.

Public Functions

inline explicit IterableIntMap( const Graph & graph )

Constructor of the map. It sets all values to -1.

inline explicit IterableIntMap( const Graph & graph , int value )

Constructor of the map with a given value.

inline int size() const

Gives back the maximal value plus one.

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 Reference operator[]( const Key & key )

Subscript operator of the map.

inline LemonRangeWrapper2< ItemIt , IterableIntMap , int > items( int 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 virtual void erase( const Key & key )
inline virtual void erase( const std::vector< Key > & keys )
inline virtual void clear()
class Reference

Reference to the value of the map.

This class is similar to the int type. It can be converted to int and it has the same operators.

Public Functions

Reference( const Reference & ) = default
inline Reference & operator=( const Reference & value )
inline operator const int&() const
inline Reference & operator=( int value )
inline Reference & operator++()
inline int operator++(int)
inline Reference & operator--()
inline int operator--(int)
inline Reference & operator+=( int value )
inline Reference & operator-=( int value )
inline Reference & operator*=( int value )
inline Reference & operator/=( int value )
inline Reference & operator%=( int value )
inline Reference & operator&=( int value )
inline Reference & operator|=( int value )
inline Reference & operator^=( int value )
inline Reference & operator<<=( int value )
inline Reference & operator>>=( int value )
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 IterableIntMap & map , int value )

Creates an iterator with a value. It iterates on the keys mapped to the given value.

Parameters:
inline ItemIt & operator++()

Increment operator.