A generic map container of typed-keys to their values. More...
#include <TypeIndexMap.hpp>
Public Member Functions | |
TypeIndexMap () | |
Empty constructor for a valid object. Initalises all values to zero. | |
template<typename IndexType> | |
void | add (const KeyType &key, ValueType val) |
Adds a value to the container. When the typed-key already exists, the value is updated. When the typed-key does not exist, a new entry is made. | |
template<typename IndexType> | |
bool | has (const KeyType &key) const |
Determines if a value is located under a given typed-key. | |
template<typename IndexType> | |
void | remove (const KeyType &key) |
Removes a value from the container. When the value removed is the last one, the typed element is removed as well. | |
std::size_t | total () const |
Gives the total number of elements in the container. | |
template<typename IndexType> | |
ValueType & | value (const KeyType &key) |
Mutable accessor to the value under a typed-key. | |
template<typename IndexType> | |
const ValueType & | value (const KeyType &key) const |
Non-mutable accessor to the value under a typed-key. | |
A generic map container of typed-keys to their values.
KeyType | The type for the typed-key. |
ValueType | The type for the values to store under the typed-key |
drn::foundation::TypeIndexMap< KeyType, ValueType >::TypeIndexMap | ( | ) |
Empty constructor for a valid object. Initalises all values to zero.
void drn::foundation::TypeIndexMap< KeyType, ValueType >::add | ( | const KeyType & | key, |
ValueType | val ) |
Adds a value to the container. When the typed-key already exists, the value is updated. When the typed-key does not exist, a new entry is made.
IndexType | The index type to place the key under. |
key | The key to place the value under. |
val | The value to place into the container. |
bool drn::foundation::TypeIndexMap< KeyType, ValueType >::has | ( | const KeyType & | key | ) | const |
Determines if a value is located under a given typed-key.
IndexType | The index type the key is expected to be under. |
key | The key to search for in the container. |
void drn::foundation::TypeIndexMap< KeyType, ValueType >::remove | ( | const KeyType & | key | ) |
Removes a value from the container. When the value removed is the last one, the typed element is removed as well.
Error | When the typed-key is not located. |
IndexType | The index type the key is expected to be under. |
key | The key to remove from the container. |
std::size_t drn::foundation::TypeIndexMap< KeyType, ValueType >::total | ( | ) | const |
Gives the total number of elements in the container.
ValueType & drn::foundation::TypeIndexMap< KeyType, ValueType >::value | ( | const KeyType & | key | ) |
Mutable accessor to the value under a typed-key.
Error | When the value is not located under a typed-key. |
IndexType | The index type the key is expected to be under. |
key | The key to get the value from under. |
const ValueType & drn::foundation::TypeIndexMap< KeyType, ValueType >::value | ( | const KeyType & | key | ) | const |
Non-mutable accessor to the value under a typed-key.
Error | When the value is not located under a typed-key. |
IndexType | The index type the key is expected to be under. |
key | The key to get the value from under. |