![]() |
0.3.0
|
Similar to KeyedMatrix, but memory is allocated in a map and therefore never reallocated. More...
Public Member Functions | |
void | addKey (const KeyType &key) |
Adds a single element for the key to the data storage. | |
void | addKey (const KeyType &key, const Scalar &value) |
Adds a single element for the key to the data storage. | |
void | addKeys (std::span< const KeyType > keys) |
Adds a continuous vector for the keys to the data storage. | |
void | addKeys (std::span< const KeyType > keys, std::span< const Scalar > values) |
Adds a continuous vector for the keys to the data storage. | |
void | addKeys (std::span< const std::pair< KeyType, Scalar > > keyValues) |
Adds a continuous vector for the keys to the data storage. | |
Scalar & | at (const KeyType &key) |
Returns a reference to the mapped value of the element with specified key. If no such element exists, an exception of type std::out_of_range is thrown. | |
const Scalar & | at (const KeyType &key) const |
Returns a reference to the mapped value of the element with specified key. If no such element exists, an exception of type std::out_of_range is thrown. | |
std::vector< Scalar > & | at (std::span< const KeyType > keys) |
Returns a reference to the mapped value of the element with specified keys. If no such element exists, an exception of type std::out_of_range is thrown. | |
const std::vector< Scalar > & | at (std::span< const KeyType > keys) const |
Returns a reference to the mapped value of the element with specified keys. If no such element exists, an exception of type std::out_of_range is thrown. | |
decltype(auto) | begin () |
Returns an iterator to the first element. | |
decltype(auto) | begin () const noexcept |
Returns an iterator to the first element. | |
decltype(auto) | cbegin () const noexcept |
Returns an iterator to the first element. | |
decltype(auto) | cend () const noexcept |
Returns an iterator to the element following the last element of. | |
void | clear () |
Erases all elements from the container. After this call, size() returns zero. | |
bool | contains (const KeyType &key) const |
Checks if there is an element with key equivalent to key in the container. | |
bool | contains (std::span< const KeyType > keys) const |
Checks if there are elements with keys equivalent to keys in the container. | |
bool | empty () const |
Checks if the container has no elements. | |
decltype(auto) | end () |
Returns an iterator to the element following the last element of. | |
decltype(auto) | end () const noexcept |
Returns an iterator to the element following the last element of. | |
std::vector< KeyType > | keys () const |
Collect all keys. | |
size_t | size () const |
Returns the number of elements in the container. | |
size_t | size_of (const KeyType &key) const |
Returns the size of parameters represented by the key. | |
Private Attributes | |
std::conditional_t< unordered, unordered_map< KeyType, std::vector< Scalar > >, std::map< KeyType, std::vector< Scalar > > > | _data |
Storage container. | |
unordered_map< KeyType, Scalar * > | _lookup |
Lookup for individual keys. | |
Similar to KeyedMatrix, but memory is allocated in a map and therefore never reallocated.
KeyType | Type to use as keys |
Scalar | Type to store in the map |
unordered | Wether an unordered_map or a std::map should be used |
|
inline |
Adds a single element for the key to the data storage.
[in] | key | Key to add |
|
inline |
Adds a single element for the key to the data storage.
[in] | key | Key to add |
[in] | value | Value for the key |
|
inline |
Adds a continuous vector for the keys to the data storage.
[in] | keys | Keys to add |
|
inline |
Adds a continuous vector for the keys to the data storage.
[in] | keys | Keys to add |
[in] | values | Values for the keys |
|
inline |
Adds a continuous vector for the keys to the data storage.
[in] | keyValues | Keys and values to add |
|
inline |
Returns a reference to the mapped value of the element with specified key. If no such element exists, an exception of type std::out_of_range is thrown.
[in] | key | the key of the element to find |
|
inlinenodiscard |
Returns a reference to the mapped value of the element with specified key. If no such element exists, an exception of type std::out_of_range is thrown.
[in] | key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with specified keys. If no such element exists, an exception of type std::out_of_range is thrown.
[in] | keys | the keys of the element to find |
|
inlinenodiscard |
Returns a reference to the mapped value of the element with specified keys. If no such element exists, an exception of type std::out_of_range is thrown.
[in] | keys | the key of the element to find |
|
inline |
Returns an iterator to the first element.
If the buffer is empty, the returned iterator will be equal to end().
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
If the buffer is empty, the returned iterator will be equal to end().
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
If the buffer is empty, the returned iterator will be equal to end().
|
inlinenodiscardnoexcept |
Returns an iterator to the element following the last element of.
This element acts as a placeholder; attempting to access it results in undefined behavior.
|
inlinenodiscard |
Checks if there is an element with key equivalent to key
in the container.
[in] | key | key value of the element to search for |
|
inlinenodiscard |
Checks if there are elements with keys equivalent to keys
in the container.
[in] | keys | keys the elements to search for |
|
inline |
Returns an iterator to the element following the last element of.
This element acts as a placeholder; attempting to access it results in undefined behavior.
|
inlinenodiscardnoexcept |
Returns an iterator to the element following the last element of.
This element acts as a placeholder; attempting to access it results in undefined behavior.
|
inlinenodiscard |
Collect all keys.
|
inlinenodiscard |
Returns the size of parameters represented by the key.
[in] | key | key value of the element to search for |