![]() |
Max OS 0.3
|
A list of key-value pairs. More...
#include <map.h>
Public Types | |
| typedef Vector< Pair< Key, Value > >::iterator | iterator |
| The iterator type for the map. | |
Public Member Functions | |
| Value & | operator[] (Key) |
| Overloads the [] operator to return the value of the key. | |
| bool | empty () |
| Returns whether the map is empty. | |
| int | size () |
| The number of elements in the map. | |
| iterator | begin () |
| Returns the beginning of the map. | |
| iterator | end () |
| Returns the end of the map. | |
| iterator | find (Key) |
| Finds an element in the map based on the key. | |
| iterator | push_back (Key, Value) |
| Adds a new key-value pair to the end of the map. | |
| Pair< Key, Value > | pop_back () |
| Removes the last key-value pair from the map and returns it. | |
| iterator | push_front (Key, Value) |
| Adds a new key-value pair to the front of the map. | |
| Pair< Key, Value > | pop_front () |
| Removes the first key-value pair from the map and returns it. | |
| void | insert (Key, Value) |
| Updates the value of an element, or adds a new element if it does not exist. | |
| void | erase (Key) |
| Removes an element from the map. | |
| void | erase (iterator position) |
| Removes an element from the map at the specified position. | |
| void | clear () |
| Removes all elements from the map. | |
| void | reserve (size_t amount) |
| Reserves space in the map for a certain amount of elements to avoid reallocations. | |
| void | increase_size () |
| Doubles the size of the map. | |
| void | iterate (MapIterationHandler< Key, Value > *handler) |
| Iterates through the map and calls the handler. | |
| void | iterate (void(*callback)(Key &, Value &)) |
| Iterates through the map and calls the callback. | |
Protected Attributes | |
| Vector< Pair< Key, Value > > | m_elements |
| The internal storage of the map, a vector of key-value pairs. | |
A list of key-value pairs.
| Key | The key type |
| Value | The value type |
| Map< Key, Value >::iterator MaxOS::common::Map< Key, Value >::begin | ( | ) |
Returns the beginning of the map.
| Key | The key type |
| Value | The value type |
Definition at line 130 of file map.h.
References MaxOS::common::Vector< Type >::begin().
Removes all elements from the map.
| Key | The key type |
| Value | The value type |
Definition at line 241 of file map.h.
References MaxOS::common::Vector< Type >::clear().
Returns whether the map is empty.
| Key | The key type |
| Value | The value type |
Definition at line 220 of file map.h.
References MaxOS::common::Vector< Type >::empty().
| Map< Key, Value >::iterator MaxOS::common::Map< Key, Value >::end | ( | ) |
Returns the end of the map.
| Key | The key type |
| Value | The value type |
Definition at line 141 of file map.h.
References MaxOS::common::Vector< Type >::end().
Referenced by MaxOS::processes::SharedMemory::open(), MaxOS::processes::SharedMemory::read(), and MaxOS::net::AddressResolutionProtocol::resolve().
| void MaxOS::common::Map< Key, Value >::erase | ( | Map< Key, Value >::iterator | position | ) |
Removes an element from the map at the specified position.
| Key | The key type |
| Value | The value type |
| position | The iterator of the element to remove |
Definition at line 293 of file map.h.
References MaxOS::common::Vector< Type >::erase().
Removes an element from the map.
| Key | The key type |
| Value | The value type |
| key | The key of the element to remove |
Definition at line 274 of file map.h.
References MaxOS::common::Vector< Type >::erase().
Referenced by MaxOS::processes::BaseResourceRegistry::close_resource().
| Map< Key, Value >::iterator MaxOS::common::Map< Key, Value >::find | ( | Key | element | ) |
Finds an element in the map based on the key.
| Key | The key type |
| Value | The value type |
| element | The key to search for |
Definition at line 153 of file map.h.
Referenced by MaxOS::processes::SharedMemory::open(), MaxOS::processes::SharedMemory::read(), and MaxOS::net::AddressResolutionProtocol::resolve().
Doubles the size of the map.
| Key | The key type |
| Value | The value type |
Definition at line 315 of file map.h.
References MaxOS::common::Vector< Type >::increase_size().
Updates the value of an element, or adds a new element if it does not exist.
| Key | The key type |
| Value | The value type |
| key | The key of the new element |
| value | The value of the new element |
Definition at line 253 of file map.h.
References MaxOS::common::Vector< Type >::push_back(), and MaxOS::common::Pair< First, Second >::second.
Referenced by MaxOS::processes::GlobalScheduler::add_process(), MaxOS::processes::GlobalScheduler::add_thread(), MaxOS::net::AddressResolutionProtocol::handle_ethernetframe_payload(), MaxOS::processes::SharedMemory::open(), MaxOS::processes::BaseResourceRegistry::register_resource(), and MaxOS::net::AddressResolutionProtocol::store().
| void MaxOS::common::Map< Key, Value >::iterate | ( | MapIterationHandler< Key, Value > * | handler | ) |
Iterates through the map and calls the handler.
| Key | The key type |
| Value | The value type |
| handler | The handler to call |
Definition at line 326 of file map.h.
References MaxOS::common::MapIterationHandler< Key, Value >::on_end_of_stream(), and MaxOS::common::MapIterationHandler< Key, Value >::on_read().
Removes the last key-value pair from the map and returns it.
| Key | The key type |
| Value | The value type |
Definition at line 185 of file map.h.
References MaxOS::common::Vector< Type >::pop_back().
Removes the first key-value pair from the map and returns it.
| Key | The key type |
| Value | The value type |
Definition at line 209 of file map.h.
References MaxOS::common::Vector< Type >::pop_front().
| Map< Key, Value >::iterator MaxOS::common::Map< Key, Value >::push_back | ( | Key | key, |
| Value | value | ||
| ) |
Adds a new key-value pair to the end of the map.
| Key | The key type |
| Value | The value type |
| key | The key |
| value | The value |
Definition at line 174 of file map.h.
References MaxOS::common::Vector< Type >::push_back().
| Map< Key, Value >::iterator MaxOS::common::Map< Key, Value >::push_front | ( | Key | key, |
| Value | value | ||
| ) |
Adds a new key-value pair to the front of the map.
| Key | The key type |
| Value | The value type |
| key | The key |
| value | The value |
Definition at line 198 of file map.h.
References MaxOS::common::Vector< Type >::push_front().
Reserves space in the map for a certain amount of elements to avoid reallocations.
| Key | The key type |
| Value | The value type |
| amount | The amount of elements to reserve space for |
Definition at line 305 of file map.h.
References MaxOS::common::Vector< Type >::reserve().
The number of elements in the map.
Definition at line 229 of file map.h.
References MaxOS::common::Vector< Type >::size().