- Main Page
- Modules
- Classes
- Namespaces
- Files
- Related Pages

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Related Functions
RangeIdMap< GR, K > Class Template Reference
Graph Maps

## Detailed Description

### template<typename GR, typename K>
class lemon::RangeIdMap< GR, K >

RangeIdMap provides a unique and continuous id for each item of a given type (`Node`, `Arc` or `Edge`) in a graph. This id is

- unique: different items get different ids,
- continuous: the range of the ids is the set of integers between 0 and `n-1`, where `n` is the number of the items of this type (`Node`, `Arc` or `Edge`).
- So, the ids can change when deleting an item of the same type.

Thus this id is not (necessarily) the same as what can get using the `id()` function of the graph or IdMap. This map can be inverted with its member class `InverseMap`, or with the `operator()()` member.

Template Parameters

  GR | The graph type.
  K | The key type of the map (`GR::Node`, `GR::Arc` or `GR::Edge`).

See Also
  IdMap

`#include <lemon/maps.h>`

Inherits Type< GR, K >.

## Classes
class | InverseMap
| The inverse map type of RangeIdMap. More...

## Public Types
typedef GR | Graph
| The graph type of RangeIdMap.
typedef K | Item
| The key type of RangeIdMap (`Node`, `Arc` or `Edge`).
typedef K | Key
| The key type of RangeIdMap (`Node`, `Arc` or `Edge`).
typedef int | Value
| The value type of RangeIdMap.

## Public Member Functions
| RangeIdMap (const Graph &gr)
| Constructor. More...
unsigned int | size () const
| Returns the maximal value plus one. More...
void | swap (const Item &p, const Item &q)
| Swaps the position of the two items in the map. More...
int | operator[] (const Item &item) const
| Gives back the range id of the item. More...
Item | operator() (int id) const
| Gives back the item belonging to a range id. More...
const InverseMap | inverse () const
| Gives back the inverse of the map. More...

## Protected Member Functions
virtual void | add (const Item &item)
| Adds a new key to the map. More...
virtual void | add (const std::vector< Item > &items)
| Add more new keys to the map. More...
virtual void | erase (const Item &item)
| Erase the key from the map. More...
virtual void | erase (const std::vector< Item > &items)
| Erase more keys from the map. More...
virtual void | build ()
| Build the unique map. More...
virtual void | clear ()
| Clear the keys from the map. More...

## Related Functions
(Note that these are not member functions.)
template<typename K , typename GR >
RangeIdMap< GR, K > | rangeIdMap (const GR &graph)
| Returns a `RangeIdMap` class. More...

## Constructor & Destructor Documentation

RangeIdMap | ( | const Graph & | gr | ) |
| inline explicit

Constructor.

## Member Function Documentation

virtual void add | ( | const Item & | item | ) |
| inline protected virtual

Add a new key to the map. It is called by the `AlterationNotifier`.

virtual void add | ( | const std::vector< Item > & | items | ) |
| inline protected virtual

Add more new keys to the map. It is called by the `AlterationNotifier`.

virtual void erase | ( | const Item & | item | ) |
| inline protected virtual

Erase the key from the map. It is called by the `AlterationNotifier`.

virtual void erase | ( | const std::vector< Item > & | items | ) |
| inline protected virtual

Erase more keys from the map. It is called by the `AlterationNotifier`.

virtual void build | ( |  | ) |
| inline protected virtual

Build the unique map. It is called by the `AlterationNotifier`.

virtual void clear | ( |  | ) |
| inline protected virtual

Clear the keys from the map. It is called by the `AlterationNotifier`.

unsigned int size | ( |  | ) | const
| inline

Returns the maximal value plus one in the map.

void swap | ( | const Item & | p,
|  | const Item & | q
| ) |  |
| inline

Swaps the position of the two items in the map.

int operator[] | ( | const Item & | item | ) | const
| inline

Gives back the range id of the item.

Item operator() | ( | int | id | ) | const
| inline

Gives back the item belonging to the given range id.

const InverseMap inverse | ( |  | ) | const
| inline

Gives back the inverse of the RangeIdMap.