RangeMap

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

template< typename V >
class RangeMap : public MapBase< int , V >

Map for storing values for integer keys from the range [0..size-1].

This map is essentially a wrapper for std::vector. It assigns values to integer keys from the range [0..size-1]. It can be used together with some data structures, e.g. heap types and UnionFind, when the used items are small integers. This map conforms to the ReferenceMap concept.

The simplest way of using this map is through the rangeMap() function.

Public Types

typedef int Key

Key type.

typedef V Value

Value type.

typedef Vector::reference Reference

Reference type.

typedef Vector::const_reference ConstReference

Const reference type.

typedef True ReferenceMapTag

Public Functions

inline RangeMap( int size = 0 , const Value & value = Value() )

Constructor with specified default value.

template< typename V1 >
inline RangeMap( const std::vector< V1 > & vector )

Constructs the map from an appropriate std::vector.

template< typename V1 >
inline RangeMap( const RangeMap< V1 > & c )

Constructs the map from another RangeMap.

inline int size() const

Returns the size of the map.

inline void resize( int size , const Value & value = Value() )

Resizes the map.

Resizes the underlying std::vector container, so changes the keyset of the map.

Parameters:
  • size – The new size of the map. The new keyset will be the range [0..size-1].

  • value – The default value to assign to the new keys.

inline Reference operator[]( const Key & k )

inline ConstReference operator[]( const Key & k ) const

inline void set( const Key & k , const Value & v )