All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Related Functions
RangeMap< V > Class Template Reference

Detailed Description

template<typename V>
class lemon::RangeMap< V >

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.

#include <lemon/maps.h>

+ Inheritance diagram for RangeMap< V >:

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.
 
- Public Types inherited from MapBase< int, V >
typedef int Key
 The key type of the map.
 
typedef V Value
 The value type of the map. (The type of objects associated with the keys).
 

Public Member Functions

 RangeMap (int size=0, const Value &value=Value())
 Constructor with specified default value.
 
template<typename V1 >
 RangeMap (const std::vector< V1 > &vector)
 Constructs the map from an appropriate std::vector.
 
template<typename V1 >
 RangeMap (const RangeMap< V1 > &c)
 Constructs the map from another RangeMap.
 
int size ()
 Returns the size of the map.
 
void resize (int size, const Value &value=Value())
 Resizes the map.
 
Reference operator[] (const Key &k)
 
 
ConstReference operator[] (const Key &k) const
 
 
void set (const Key &k, const Value &v)
 
 

Related Functions

(Note that these are not member functions.)

template<typename V >
RangeMap< V > rangeMap (int size=0, const V &value=V())
 Returns a RangeMap class.
 
template<typename V >
RangeMap< V > rangeMap (const std::vector< V > &vector)
 Returns a RangeMap class created from an appropriate std::vector.
 

Member Function Documentation

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

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

Parameters
sizeThe new size of the map. The new keyset will be the range [0..size-1].
valueThe default value to assign to the new keys.