Class Map
Set/dictionary container.

All Subcl's Skiplist, VectorSet
Defined in <seqan/map.h>
Signature template <typename TValue, typename TSpec> class Map;

Template Parameters

TSpec The specializing type. Default: Skiplist
TValue Type of values that are stored in the map. Use a Pair<Key, Cargo> to implement a dictionary mapping from Key to Cargo.

Interface Function Overview

Interface Metafunction Overview

Interface Functions Detail

void add(map, value); void add(map, key, cargo);

Insert another value into a multi map.

Parameters

map A map. Types: Skiplist
value A value that is added to map.
cargo A cargo.
key A key.

If key and cargo are specified, a new value of that key and value is added.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TCargo find(map, key);

Returns a cargo given a key.

Parameters

map A map.
key A key.

Returns

TReturn The cargo of the first value in map of the given key, if there is any. Otherwise, the cargo of a new value that is inserted to map.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

void erase(map, key); void erase(map, iterator);

Removes a value from a map.

Parameters

map A map. Types: Map
key The key of a value in map.
iterator An iterator to a value in map.

Removes the first value in map of the given key, if there is any.

Use eraseAll to remove all values of the given key in a multi map.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

void eraseAll(map, key);

Removes a value from a map.

Parameters

map A map. Types: Skiplist
key The key of a value in map.

Removes all values in map of the given key, if there is any.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TIterator find(map, key);

Find a value in a map.

Parameters

map A map. Types: Map
key A key.

Returns

TIterator An iterator to the first value in map of the given key, if there is any. An iterator to the fist value in map with key > key, otherwise.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

See Also

bool hasKey(map, key);

Determines whether a map contains a value given key.

Parameters

map A map. Types: Map
key A key.

Returns

bool true, if there is a value in map of that key, false otherwise.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

void insert(map, value); void insert(map, key, cargo);

Insert new value into map.

Parameters

map A map.
value A value that is added to map.
key A key.
cargo A cargo.

If key and cargo are specified, a new value of that key and value is added. If there is already a value of that key in map, the value of this element is changed to cargo.

If value is specified, and there is already a value in map of that key, than the cargo of this value is changed to cargo.cargo(value).

Use Map#add instead to insert multiple values of the same key.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TSize length(map);

Return number of elements in map.

Parameters

map The Map to query for its size.

Returns

TSize The number of elements in the map.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TMapValue mapValue(map, key);

Subscript operator[] of maps.

Parameters

map A map. Types: Map
key A key.

Returns

TMapValue If map is a set: The same as Map#hasKey. If map is a dictionary: The same as Map#value.

Remarks

Usually, Map#value implements the subscript operator [ ], but for maps, this operator is implemented in mapValue. The semantic of this operator depends on the kind of map: If the map has a Cargo.cargo, than mapValue(map, key) returns the cargo of the (first) value in the map of the given key. If the map has no Cargo.cargo, than the function returns a true, if key is in map, or false otherwise.

Remarks

There is no way to create a set of Pair, since it is always interpreted as a key/value pair. If you need a key type that holds two members, define your own key type.

You may overload Key and Cargo for your own value type in order to define, what part of your value type is used as key and what as cargo.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TReference value(map, key);

Note.

Do not change the key of a value in the map.

Returns a value given a key.

Parameters

map A map.
key A key.

Returns

TReference The first value in map of the given key, if there is any. Otherwise, a new value that is inserted to map.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

Interface Metafunctions Detail

MapValue<T>::Type

Type of the map value type.

Template Parameters

T A map type. Types: Map

Returns

Type the map value type.