Map collection.
More...
#include <base/collection/Map.h>
Inherits Collection.
template<class KEY, class VALUE>
class Map< KEY, VALUE >
Map collection.
Map collection implemented using an ordered binary tree.
- Version
- 1.1
- Examples
- testsuite/Map.cpp.
◆ Key
template<class KEY , class VALUE >
typedef KEY Map< KEY, VALUE >::Key |
The type of a key in the map.
◆ Node
template<class KEY , class VALUE >
The type of an association in the map.
◆ Value
template<class KEY , class VALUE >
The type of a value in the map.
◆ Map() [1/4]
template<class KEY , class VALUE >
Initializes an empty map.
◆ Map() [2/4]
template<class KEY , class VALUE >
Map< KEY, VALUE >::Map |
( |
std::initializer_list< Node > |
values | ) |
|
|
inline |
Initializes map with given values.
◆ Map() [3/4]
template<class KEY , class VALUE >
Map< KEY, VALUE >::Map |
( |
const Map< KEY, VALUE > & |
copy | ) |
|
|
inlinenoexcept |
Initializes map from other map.
◆ Map() [4/4]
template<class KEY , class VALUE >
Map< KEY, VALUE >::Map |
( |
Map< KEY, VALUE > && |
move | ) |
|
|
inlinenoexcept |
Initializes map from other map.
◆ add() [1/2]
template<class KEY , class VALUE >
bool Map< KEY, VALUE >::add |
( |
const Key & |
key, |
|
|
const Value & |
value |
|
) |
| |
|
inline |
Associates the specified key with the specified value in this map. If the key already is associated with a value, the value is overridden.
- Parameters
-
key | The key. |
value | The value. |
- Returns
- Returns true if new key was added.
◆ add() [2/2]
template<class KEY , class VALUE >
bool Map< KEY, VALUE >::add |
( |
const Key & |
key, |
|
|
Value && |
value |
|
) |
| |
|
inline |
Associates the specified key with the specified value in this map. If the key already is associated with a value, the value is overridden.
- Parameters
-
key | The key. |
value | The value. |
- Returns
- Returns true if new key was added.
◆ find() [1/2]
template<class KEY , class VALUE >
Returns the value associated with the specified key.
- Parameters
-
- Returns
- nullptr is key doesn't exist.
◆ find() [2/2]
template<class KEY , class VALUE >
const Value* Map< KEY, VALUE >::find |
( |
const Key & |
key | ) |
const |
|
inline |
Returns the value associated with the specified key.
- Parameters
-
- Returns
- nullptr is key doesn't exist.
◆ getReadEnumerator()
template<class KEY , class VALUE >
Returns a non-modifying enumerator of the ordered binary tree.
◆ getSize()
template<class KEY , class VALUE >
MemorySize Map< KEY, VALUE >::getSize |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of associations in the map.
◆ getValue() [1/2]
template<class KEY , class VALUE >
Returns the value associated with the specified key. Raises InvalidKey if the specified key doesn't exist in this map.
- Parameters
-
◆ getValue() [2/2]
template<class KEY , class VALUE >
const Value& Map< KEY, VALUE >::getValue |
( |
const Key & |
key | ) |
const |
|
inline |
Returns the value associated with the specified key. Raises InvalidKey if the specified key doesn't exist in this map.
- Parameters
-
◆ getValueEnumerator()
template<class KEY , class VALUE >
Returns a modifying enumerator of the ordered binary tree.
◆ hasKey()
template<class KEY , class VALUE >
bool Map< KEY, VALUE >::hasKey |
( |
const Key & |
key | ) |
const |
|
inlinenoexcept |
Returns true if the specified key is associated with a value in this map.
- Parameters
-
key | The value to search for. |
◆ isEmpty()
template<class KEY , class VALUE >
bool Map< KEY, VALUE >::isEmpty |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the map is empty.
◆ operator bool()
template<class KEY , class VALUE >
Map< KEY, VALUE >::operator bool |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the map is not empty.
◆ operator<<() [1/2]
template<class KEY , class VALUE >
Map& Map< KEY, VALUE >::operator<< |
( |
const Node & |
value | ) |
|
|
inline |
◆ operator<<() [2/2]
template<class KEY , class VALUE >
Map& Map< KEY, VALUE >::operator<< |
( |
Node && |
value | ) |
|
|
inline |
◆ operator=() [1/2]
template<class KEY , class VALUE >
Map& Map< KEY, VALUE >::operator= |
( |
const Map< KEY, VALUE > & |
copy | ) |
|
|
inline |
Assignment of map to map.
◆ operator=() [2/2]
template<class KEY , class VALUE >
Map& Map< KEY, VALUE >::operator= |
( |
Map< KEY, VALUE > && |
move | ) |
|
|
inline |
Assignment of map to map.
◆ operator[]() [1/2]
template<class KEY , class VALUE >
Value& Map< KEY, VALUE >::operator[] |
( |
const Key & |
key | ) |
|
|
inline |
Returns the value associated with the specified key.
◆ operator[]() [2/2]
template<class KEY , class VALUE >
const Value& Map< KEY, VALUE >::operator[] |
( |
const Key & |
key | ) |
const |
|
inline |
Returns the value associated with the specified key.
◆ remove()
template<class KEY , class VALUE >
void Map< KEY, VALUE >::remove |
( |
const Key & |
key | ) |
|
|
inline |
Removes the specified key and its associated value from this map. Raises InvalidKey if the key doesn't exist in this map.
◆ removeAll()
template<class KEY , class VALUE >
void Map< KEY, VALUE >::removeAll |
( |
| ) |
|
|
inline |
Removes all the keys from this map.
◆ operator<<()
template<class KEY , class VALUE >
Writes a string representation of a map to a format stream.