|
jaulib v1.4.1-10-ga2c96e0
Jau Support Library (C++, Java, ..)
|
HashMapWrap, generic std::unordered_map exposing a more higher level API. More...
#include <basic_collections.hpp>
Public Types | |
| typedef const value_type & | const_reference |
| typedef Hash_functor | hash_functor |
| typedef std::unordered_map< key_type, value_type, hash_functor, KeyEqual, Allocator > | HashMapType |
| typedef Key_type | key_type |
| typedef Novalue_type | novalue_type |
| typedef HashMapType::value_type | pair_type |
| typedef Query_type | query_type |
| typedef value_type & | reference |
| typedef HashMapType::size_type | size_type |
| typedef Value_type | value_type |
Public Member Functions | |
| void | clear () |
| Clears the hash map. | |
| bool | containsKey (const query_type &key) const |
Returns true if the given key maps to a value or no_value. | |
| std::optional< const key_type & > | containsValue (const_reference value) const |
| Returns the key reference of the first value, otherwise std::nullopt. | |
| const pair_type * | find (const query_type &key) const |
| Returns the immutable pair_type pointer for the given key or nullptr. | |
| reference | get (const query_type &key) |
| Returns the mutable mapped value reference for the given key or novalue() | |
| const_reference | get (const query_type &key) const |
| Returns the immutable mapped value reference for the given key or novalue() | |
| bool | insert (const key_type &key, const_reference obj) |
| Adds a new mapping of the value for the given key, does nothing if a mapping exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| bool | insert (const Q &key, const_reference obj) |
| Adds a new mapping of the value for the given key, does nothing if a mapping exists. | |
| const HashMapType & | map () const noexcept |
| HashMapType & | map () noexcept |
| converts novalue_type No_value to lvalue value_type to return its reference | |
| constexpr const_reference | novalue () const noexcept |
Returns the no-value immutable refererence no_value | |
| constexpr reference | novalue () noexcept |
Returns the no-value mutable refererence, no_value (should not be writable or written to) | |
| bool | put (const key_type &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| bool | put (const Q &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| reference | put2 (const key_type &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| reference | put2 (const Q &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| value_type | put3 (const key_type &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| value_type | put3 (const Q &key, const_reference obj) |
| Maps the value for the given key, overwrites old mapping if exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| bool | remove (const Q &key) |
| Removes value if mapped and returns true, otherwise returns false. | |
| bool | remove (const query_type &key) |
| Removes value if mapped and returns true, otherwise returns false. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| value_type | remove2 (const Q &key) |
Removes value if mapped and returns it, otherwise returns no_value. | |
| value_type | remove2 (const query_type &key) |
Removes value if mapped and returns it, otherwise returns no_value. | |
| bool | replace (const key_type &key, const_reference obj) |
| Replaces the already mapped value for the given key, does nothing if no mapping exists. | |
| template<class Q> requires (!std::same_as<key_type, query_type>) && std::same_as<Q, query_type> | |
| bool | replace (const Q &key, const_reference obj) |
| Replaces the already mapped value for the given key, does nothing if no mapping exists. | |
| size_type | size () const noexcept |
HashMapWrap, generic std::unordered_map exposing a more higher level API.
Allows using No_value for queries to signal no value found in map.
no_value will be returned by reference, including mutable reference. Hence caller must ensure that this special value is detected and not written to. This path has been chosen in favor of returning a nullptr.
| Key_type | key type |
| Value_type | value type |
| Novalue_type | value type representing no value, e.g. Value_type or std::nullptr_t for pointer. Requirement: Value_type must be constructible from Novalue_type. |
| No_value | no value query result of Novalue_type type, e.g. a Value_type -1, MAX_VALUE or nullptr for std::nullptr_t |
| Hash_functor | Hashing function object type, defaults to std::hash<Key_type> |
| Query_type | key query type, defaults to Key_type. Allows to sooth query parameter, e.g. string_view instead of string. Requirement: Key_type must be constructible from Query_type. |
| KeyEqual | Comparator function object type, defaults to std::equal_to<> |
| Allocator | Allocator type, defaults to std::allocator<std::pair<const Key_type, Value_type>> |
Definition at line 123 of file basic_collections.hpp.
| typedef Key_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::key_type |
Definition at line 125 of file basic_collections.hpp.
| typedef Query_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::query_type |
Definition at line 126 of file basic_collections.hpp.
| typedef Hash_functor jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::hash_functor |
Definition at line 127 of file basic_collections.hpp.
| typedef Value_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::value_type |
Definition at line 128 of file basic_collections.hpp.
| typedef value_type& jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::reference |
Definition at line 131 of file basic_collections.hpp.
| typedef const value_type& jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::const_reference |
Definition at line 132 of file basic_collections.hpp.
| typedef Novalue_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::novalue_type |
Definition at line 133 of file basic_collections.hpp.
| typedef std::unordered_map<key_type, value_type, hash_functor, KeyEqual, Allocator> jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::HashMapType |
Definition at line 135 of file basic_collections.hpp.
| typedef HashMapType::size_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::size_type |
Definition at line 136 of file basic_collections.hpp.
| typedef HashMapType::value_type jau::HashMapWrap< Key_type, Value_type, Novalue_type, No_value, Hash_functor, Query_type, KeyEqual, Allocator >::pair_type |
Definition at line 137 of file basic_collections.hpp.
|
inlinenoexcept |
converts novalue_type No_value to lvalue value_type to return its reference
Definition at line 144 of file basic_collections.hpp.
|
inlinenoexcept |
Definition at line 145 of file basic_collections.hpp.
|
inlineconstexprnoexcept |
Returns the no-value immutable refererence no_value
Definition at line 148 of file basic_collections.hpp.
|
inlineconstexprnoexcept |
Returns the no-value mutable refererence, no_value (should not be writable or written to)
Definition at line 150 of file basic_collections.hpp.
|
inlinenoexcept |
|
inline |
Clears the hash map.
Definition at line 155 of file basic_collections.hpp.
|
inline |
Returns the immutable mapped value reference for the given key or novalue()
Definition at line 158 of file basic_collections.hpp.
|
inline |
Returns the mutable mapped value reference for the given key or novalue()
Definition at line 166 of file basic_collections.hpp.
|
inline |
Returns the immutable pair_type pointer for the given key or nullptr.
Definition at line 175 of file basic_collections.hpp.
|
inline |
Returns true if the given key maps to a value or no_value.
Definition at line 184 of file basic_collections.hpp.
|
inline |
Returns the key reference of the first value, otherwise std::nullopt.
Note: O(n) operation, slow.
Definition at line 189 of file basic_collections.hpp.
|
inline |
Adds a new mapping of the value for the given key, does nothing if a mapping exists.
Definition at line 202 of file basic_collections.hpp.
|
inline |
Adds a new mapping of the value for the given key, does nothing if a mapping exists.
Definition at line 213 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Definition at line 221 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Definition at line 238 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Consider using put() if old replaced value is not of interest.
Definition at line 256 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Consider using put() if old replaced value is not of interest.
Definition at line 277 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Consider using put() if old replaced value is not of interest.
no_value. Definition at line 294 of file basic_collections.hpp.
|
inline |
Maps the value for the given key, overwrites old mapping if exists.
Consider using put() if old replaced value is not of interest.
no_value. Definition at line 315 of file basic_collections.hpp.
|
inline |
Replaces the already mapped value for the given key, does nothing if no mapping exists.
Definition at line 330 of file basic_collections.hpp.
|
inline |
Replaces the already mapped value for the given key, does nothing if no mapping exists.
Definition at line 346 of file basic_collections.hpp.
|
inline |
Removes value if mapped and returns true, otherwise returns false.
Definition at line 356 of file basic_collections.hpp.
|
inline |
Removes value if mapped and returns true, otherwise returns false.
Definition at line 369 of file basic_collections.hpp.
|
inline |
Removes value if mapped and returns it, otherwise returns no_value.
Consider using remove() if removed value is not of interest.
no_value. Definition at line 385 of file basic_collections.hpp.
|
inline |
Removes value if mapped and returns it, otherwise returns no_value.
Consider using remove() if removed value is not of interest.
no_value. Definition at line 405 of file basic_collections.hpp.