#include <rtmap.h>
Public Types | |
|
typedef Iterator< Pair< K, V > > | Iterator |
| The map iterator type: You can alternatively use Iterator<Map<K,V>::Pair> or Map<K,V>::Iterator (which is somewhat shorter). | |
Public Methods | |
| Map () | |
| Creates a new empty map. More... | |
| Map (int(*compareFun)(const K &, const K &)) | |
| Creates a new empty map, whose entries are sorted with a given comparison function. | |
| Map (const Map &) | |
| Creates a new map, copying all the contents over from the given map. | |
| virtual | ~Map () |
| const Map & | operator= (const Map &) |
| Clears this map, then copies all the contents of the given map into it. | |
| bool | isSet (const K &) const |
Returns True if there is a mapping for the given key in this map. | |
| const V & | get (const K &) const |
Returns a constant reference to the value the given key is mapped to, or noValue.getValue() if it is not mapped to anything. | |
| V & | get (const K &) |
| Returns a modifiable reference to the value the given key is mapped to, or if it was not mapped to anything, inserts the key into the map, so that the reference can be assigned to something. | |
| Pair< K, V > & | put (const K &, const V &) |
| Put a new mapping of the given key and value into the map. More... | |
| void | putAll (const Map< K, V > &) |
| Copies all mappings from the given map into this one. More... | |
| bool | remove (const K &) |
| Removes the mapping of the given key from this map. More... | |
| void | remove (Iterator &iter) |
| Removes the mapping the given iterator points to. More... | |
| void | clear () |
| Clears this map by removing and deleting all entries. | |
| const V & | operator[] (const K &) const |
Returns a constant reference to the value the given key is mapped to, or noValue.getValue() if it is not mapped to anything. | |
| V & | operator[] (const K &) |
| Returns a modifiable reference to the value the given key is mapped to, or if it was not mapped to anything, inserts the key into the map, so that the reference can be assigned to something. | |
| int | length () const |
| Returns the element count of this map. | |
| Iterator | begin () const |
| Returns an unmodifyable iterator to the first element of the map. More... | |
| Iterator | end () const |
| Returns an unmodifyable iterator to the last element of the map. More... | |
| Iterator | begin () |
| Returns a modifyable iterator to the first element of the map. More... | |
| Iterator | end () |
| Returns a modifyable iterator to the last element of the map. More... | |
Static Public Attributes | |
| Pair< K, V > | noValue |
| The pair which is defined to be no value. | |
Protected Attributes | |
| int(* | compareFun )(const K &, const K &) |
| The function used to compare the keys. | |
This implementation of a map uses a linked list to store its data and it therefore quite slow (for large data sets).
Note: All types which should be used as keys in a Map must implement the comparison operators < and ==!
|
|||||||||
|
Creates a new empty map.
The map entries are sorted using the default |
|
|||||||||
|
Returns a modifyable iterator to the first element of the map. If the map is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this. |
|
|||||||||
|
Returns an unmodifyable iterator to the first element of the map. If the map is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this. |
|
|||||||||
|
Returns a modifyable iterator to the last element of the map. If the map is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this. |
|
|||||||||
|
Returns an unmodifyable iterator to the last element of the map. If the map is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this. |
|
||||||||||||||||
|
Put a new mapping of the given key and value into the map. If the given key was already mapped to something, the mapping is replaced.
|
|
||||||||||
|
Copies all mappings from the given map into this one. Existing mappings are replaced (if they have the same key). |
|
||||||||||
|
Removes the mapping the given iterator points to. Moves the iterator to the next mapping of the list. |
|
||||||||||
|
Removes the mapping of the given key from this map. If the key was not mapped to anything, just does nothing.
|