◆ key_type
template<typename Key , typename Value >
◆ mapped_type
template<typename Key , typename Value >
◆ size_type
template<typename Key , typename Value >
Type used to measure element size.
◆ value_type
template<typename Key , typename Value >
◆ map()
template<typename Key , typename Value >
Constructs an empty map with standard memory allocation.
- Returns
- a new empty map
◆ begin()
template<typename Key , typename Value >
Return iterator to beginning.
Returns an iterator pointing to the first element in the map. If the container is empty, the returned iterator value shall not be dereferenced.
- Returns
- an iterator to the beginning of the container
◆ clear()
template<typename Key , typename Value >
Removes all elements from the map, leaving the container with a size of 0.
◆ custom_allocation_map()
template<typename Key , typename Value >
Constructs an empty map using custom CMagic memory allocation from memory.h.
- Returns
- a new empty map
◆ empty()
template<typename Key , typename Value >
Returns whether the map is empty (i.e. whether its size is 0).
This function does not modify the container in any way. To clear the content of a map, see map::clear.
- Returns
true
if the container size is 0, false
otherwise
◆ end()
template<typename Key , typename Value >
Return iterator to end.
It does not point to any element, and thus shall not be dereferenced.
- Returns
- an iterator to the element past the end of the sequence
◆ erase()
template<typename Key , typename Value >
Removes a single element from the map.
- Parameters
-
key | key of the value to be removed from the map. Function does nothing if the key doesn't exist in the map. |
◆ find()
template<typename Key , typename Value >
Searches the container for an element with a key equivalent to key
and returns an iterator to it if found, otherwise it returns map::end.
- Parameters
-
key | key to be searched for |
- Returns
- an iterator to the element, if
key
is found, or map::end otherwise
◆ insert() [1/2]
template<typename Key , typename Value >
Inserts a new element to the map if its key is not equivalent to any element already contained in the map.
Because keys in a map are unique, the insertion operation checks whether an inserted element is equivalent to an element already in the container, and if so, the element is not inserted, returning an iterator to this existing element.
- Parameters
-
val | value to be copied (or moved) to the map |
- Returns
- a pair, with its member
pair::first
map to an iterator pointing to either the newly inserted element or to the equivalent element already in the map or end if allocation of the new element has failed. The pair::second
element in the pair is set to true
if a new element was inserted or false
if an equivalent element already existed (or could not be inserted due to allocation failure).
◆ insert() [2/2]
template<typename Key , typename Value >
Inserts a new element to the map if its key is not equivalent to any element already contained in the map.
Because keys in a map are unique, the insertion operation checks whether an inserted element is equivalent to an element already in the container, and if so, the element is not inserted, returning an iterator to this existing element.
- Parameters
-
val | value to be copied (or moved) to the map |
- Returns
- a pair, with its member
pair::first
map to an iterator pointing to either the newly inserted element or to the equivalent element already in the map or end if allocation of the new element has failed. The pair::second
element in the pair is set to true
if a new element was inserted or false
if an equivalent element already existed (or could not be inserted due to allocation failure).
◆ operator bool()
template<typename Key , typename Value >
Checks if the map is properly initialized.
Example usage:
if (map) {
} else {
std::cerr << "Map allocation failed!\n";
}
- Returns
true
if map is initialized, false
if map allocation has failed and no operation should be made on it
◆ size()
template<typename Key, typename Value>
Returns the number of elements in the map.
- Returns
- number of elements in the map
The documentation for this class was generated from the following file: