![]() |
SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
|
Compile-time hash-map (associative key-value container) that performs all operations in constexpr context. This means that keys and values have to be constexpr and noexcept constructible and provide constexpr noexcept operator=. More...
#include <hash_map.hpp>
Public Types | |
| using | key_type = K |
| using | value_type = V |
| using | size_type = decltype(N) |
| using | data_type = std::array<std::pair<K, V>, N> |
| underlying structure used for the actual implementation | |
| using | const_iterator = typename data_type::const_iterator |
Public Member Functions | |
| template<typename... E> | |
| constexpr | hash_map (E &&...elements) noexcept |
| The only construction that might be used, all keys and values must be provided in the constructor. | |
| constexpr const_iterator | find (const K &key) const noexcept |
| Searches map for a given key and returns iterator. | |
| constexpr std::pair< bool, const V & > | at (const K &key) const noexcept |
| Searches for a given key, aimed to return associated value with it. | |
| constexpr const V & | operator[] (const K &key) const noexcept |
| Retrieves reference to constant to a value. Doesn't perform any bounds checking, behaviour is undefined if the key doesn't exist. | |
| constexpr bool | contains (const K &key) const noexcept |
| Checks if element with given key exists. | |
| constexpr size_type | size () const noexcept |
| Retrieves size of a hash-map, might also be called indirectly using the std::size(...). | |
| constexpr const_iterator | begin () const noexcept |
| Gives constant iterator to a beginning, needed for the C++11 for-each cycle or the std::for_each. | |
| constexpr const_iterator | cbegin () const noexcept |
| Gives constant iterator to a beginning, might be also called using std::cbegin(...). | |
| constexpr const_iterator | end () const noexcept |
| Gives constant iterator to an end, needed for the C++11 for-each cycle or the std::for_each. | |
| constexpr const_iterator | cend () const noexcept |
| Gives constant iterator to a beginning, might be also called using std::cend(...). | |
| constexpr bool | empty () const noexcept |
| Hash-map cannot be empty; this might also be called using std::empty(...). | |
| constexpr std::array< K, N > | keys () const noexcept |
| Returns all keys in the hash-map. | |
Protected Member Functions | |
| template<const auto... KeyIdx> | |
| constexpr std::array< K, N > | keys_impl (std::index_sequence< KeyIdx... >) const |
Compile-time hash-map (associative key-value container) that performs all operations in constexpr context. This means that keys and values have to be constexpr and noexcept constructible and provide constexpr noexcept operator=.
Behaviour is undefined, if there are multiple same keys.
There's actually no hash function needed, see details section.
Implemented as an std::array containing pairs, so no hashing is involved.
| N | total number of elements |
| K | data type for keys |
| V | data type for values |
Definition at line 65 of file hash_map.hpp.
| using satnogs::comms::utils::hash_map< N, K, V >::const_iterator = typename data_type::const_iterator |
Definition at line 77 of file hash_map.hpp.
| using satnogs::comms::utils::hash_map< N, K, V >::data_type = std::array<std::pair<K, V>, N> |
underlying structure used for the actual implementation
Definition at line 75 of file hash_map.hpp.
| using satnogs::comms::utils::hash_map< N, K, V >::key_type = K |
Definition at line 69 of file hash_map.hpp.
| using satnogs::comms::utils::hash_map< N, K, V >::size_type = decltype(N) |
Definition at line 73 of file hash_map.hpp.
| using satnogs::comms::utils::hash_map< N, K, V >::value_type = V |
Definition at line 71 of file hash_map.hpp.
|
inlineexplicitconstexprnoexcept |
The only construction that might be used, all keys and values must be provided in the constructor.
| R | variadic arguments automatically deduced by the compiler |
| elements | series of std::pair<K, V>, cannot be empty |
Definition at line 84 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Searches for a given key, aimed to return associated value with it.
| key | key to be searched for |
Deliberately not throwing an exception, and returning pair instead, as this generates much shorter assembly on clang and msvc
Definition at line 109 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Gives constant iterator to a beginning, needed for the C++11 for-each cycle or the std::for_each.
Definition at line 155 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Gives constant iterator to a beginning, might be also called using std::cbegin(...).
Definition at line 165 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Gives constant iterator to a beginning, might be also called using std::cend(...).
Definition at line 185 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Checks if element with given key exists.
| key | key to be searched for |
Definition at line 136 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Hash-map cannot be empty; this might also be called using std::empty(...).
Definition at line 195 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Gives constant iterator to an end, needed for the C++11 for-each cycle or the std::for_each.
Definition at line 175 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Searches map for a given key and returns iterator.
| key | key to be searched for |
Definition at line 96 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns all keys in the hash-map.
Definition at line 203 of file hash_map.hpp.
|
inlinenodiscardconstexprprotected |
Definition at line 248 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Retrieves reference to constant to a value. Doesn't perform any bounds checking, behaviour is undefined if the key doesn't exist.
| key | key to be searched for |
Definition at line 127 of file hash_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Retrieves size of a hash-map, might also be called indirectly using the std::size(...).
Definition at line 145 of file hash_map.hpp.