array-hash
|
#include <array_map.h>
Public Types | |
using | char_type = typename ht::char_type |
using | mapped_type = T |
using | key_size_type = typename ht::key_size_type |
using | index_size_type = typename ht::index_size_type |
using | size_type = typename ht::size_type |
using | hasher = typename ht::hasher |
using | key_equal = typename ht::key_equal |
using | iterator = typename ht::iterator |
using | const_iterator = typename ht::const_iterator |
Public Member Functions | |
array_map () | |
array_map (size_type bucket_count, const Hash &hash=Hash()) | |
template<class InputIt , typename std::enable_if< is_iterator< InputIt >::value >::type * = nullptr> | |
array_map (InputIt first, InputIt last, size_type bucket_count=ht::DEFAULT_INIT_BUCKET_COUNT, const Hash &hash=Hash()) | |
array_map (std::initializer_list< std::pair< const CharT *, T >> init, size_type bucket_count=ht::DEFAULT_INIT_BUCKET_COUNT, const Hash &hash=Hash()) | |
array_map & | operator= (std::initializer_list< std::pair< const CharT *, T >> ilist) |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
bool | empty () const noexcept |
size_type | size () const noexcept |
size_type | max_size () const noexcept |
size_type | max_key_size () const noexcept |
void | shrink_to_fit () |
void | clear () noexcept |
std::pair< iterator, bool > | insert (const CharT *key, const T &value) |
std::pair< iterator, bool > | insert (const std::basic_string< CharT > &key, const T &value) |
std::pair< iterator, bool > | insert_ks (const CharT *key, size_type key_size, const T &value) |
std::pair< iterator, bool > | insert (const CharT *key, T &&value) |
std::pair< iterator, bool > | insert (const std::basic_string< CharT > &key, T &&value) |
std::pair< iterator, bool > | insert_ks (const CharT *key, size_type key_size, T &&value) |
template<class InputIt , typename std::enable_if< is_iterator< InputIt >::value >::type * = nullptr> | |
void | insert (InputIt first, InputIt last) |
void | insert (std::initializer_list< std::pair< const CharT *, T >> ilist) |
template<class M > | |
std::pair< iterator, bool > | insert_or_assign (const CharT *key, M &&obj) |
template<class M > | |
std::pair< iterator, bool > | insert_or_assign (const std::basic_string< CharT > &key, M &&obj) |
template<class M > | |
std::pair< iterator, bool > | insert_or_assign_ks (const CharT *key, size_type key_size, M &&obj) |
template<class... Args> | |
std::pair< iterator, bool > | emplace (const CharT *key, Args &&... args) |
template<class... Args> | |
std::pair< iterator, bool > | emplace (const std::basic_string< CharT > &key, Args &&... args) |
template<class... Args> | |
std::pair< iterator, bool > | emplace_ks (const CharT *key, size_type key_size, Args &&... args) |
iterator | erase (const_iterator pos) |
iterator | erase (const_iterator first, const_iterator last) |
size_type | erase (const CharT *key) |
size_type | erase (const std::basic_string< CharT > &key) |
size_type | erase_ks (const CharT *key, size_type key_size) |
size_type | erase (const CharT *key, std::size_t precalculated_hash) |
size_type | erase (const std::basic_string< CharT > &key, std::size_t precalculated_hash) |
size_type | erase_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) |
void | swap (array_map &other) |
T & | at (const CharT *key) |
const T & | at (const CharT *key) const |
T & | at (const std::basic_string< CharT > &key) |
const T & | at (const std::basic_string< CharT > &key) const |
T & | at_ks (const CharT *key, size_type key_size) |
const T & | at_ks (const CharT *key, size_type key_size) const |
T & | at (const CharT *key, std::size_t precalculated_hash) |
const T & | at (const CharT *key, std::size_t precalculated_hash) const |
T & | at (const std::basic_string< CharT > &key, std::size_t precalculated_hash) |
const T & | at (const std::basic_string< CharT > &key, std::size_t precalculated_hash) const |
T & | at_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) |
const T & | at_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) const |
T & | operator[] (const CharT *key) |
T & | operator[] (const std::basic_string< CharT > &key) |
size_type | count (const CharT *key) const |
size_type | count (const std::basic_string< CharT > &key) const |
size_type | count_ks (const CharT *key, size_type key_size) const |
size_type | count (const CharT *key, std::size_t precalculated_hash) const |
size_type | count (const std::basic_string< CharT > &key, std::size_t precalculated_hash) const |
size_type | count_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) const |
iterator | find (const CharT *key) |
const_iterator | find (const CharT *key) const |
iterator | find (const std::basic_string< CharT > &key) |
const_iterator | find (const std::basic_string< CharT > &key) const |
iterator | find_ks (const CharT *key, size_type key_size) |
const_iterator | find_ks (const CharT *key, size_type key_size) const |
iterator | find (const CharT *key, std::size_t precalculated_hash) |
const_iterator | find (const CharT *key, std::size_t precalculated_hash) const |
iterator | find (const std::basic_string< CharT > &key, std::size_t precalculated_hash) |
const_iterator | find (const std::basic_string< CharT > &key, std::size_t precalculated_hash) const |
iterator | find_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) |
const_iterator | find_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) const |
std::pair< iterator, iterator > | equal_range (const CharT *key) |
std::pair< const_iterator, const_iterator > | equal_range (const CharT *key) const |
std::pair< iterator, iterator > | equal_range (const std::basic_string< CharT > &key) |
std::pair< const_iterator, const_iterator > | equal_range (const std::basic_string< CharT > &key) const |
std::pair< iterator, iterator > | equal_range_ks (const CharT *key, size_type key_size) |
std::pair< const_iterator, const_iterator > | equal_range_ks (const CharT *key, size_type key_size) const |
std::pair< iterator, iterator > | equal_range (const CharT *key, std::size_t precalculated_hash) |
std::pair< const_iterator, const_iterator > | equal_range (const CharT *key, std::size_t precalculated_hash) const |
std::pair< iterator, iterator > | equal_range (const std::basic_string< CharT > &key, std::size_t precalculated_hash) |
std::pair< const_iterator, const_iterator > | equal_range (const std::basic_string< CharT > &key, std::size_t precalculated_hash) const |
std::pair< iterator, iterator > | equal_range_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) |
std::pair< const_iterator, const_iterator > | equal_range_ks (const CharT *key, size_type key_size, std::size_t precalculated_hash) const |
size_type | bucket_count () const |
size_type | max_bucket_count () const |
float | load_factor () const |
float | max_load_factor () const |
void | max_load_factor (float ml) |
void | rehash (size_type count) |
void | reserve (size_type count) |
hasher | hash_function () const |
key_equal | key_eq () const |
iterator | mutable_iterator (const_iterator it) noexcept |
template<class Serializer > | |
void | serialize (Serializer &serializer) const |
Static Public Member Functions | |
template<class Deserializer > | |
static array_map | deserialize (Deserializer &deserializer, bool hash_compatible=false) |
Static Public Attributes | |
static const size_type | MAX_KEY_SIZE = ht::MAX_KEY_SIZE |
Friends | |
bool | operator== (const array_map &lhs, const array_map &rhs) |
bool | operator!= (const array_map &lhs, const array_map &rhs) |
void | swap (array_map &lhs, array_map &rhs) |
Implementation of a cache-conscious string hash map.
The map stores the strings as const CharT*
. If StoreNullTerminator
is true, the strings are stored with the a null-terminator (the key()
method of the iterators will return a pointer to this null-terminated string). Otherwise the null character is not stored (which allow an economy of 1 byte per string).
The value T
must be either nothrow move-constructible, copy-constuctible or both.
The size of a key string is limited to std::numeric_limits<KeySizeT>::max() - 1
. That is 65 535 characters by default, but can be raised with the KeySizeT
template parameter. See max_key_size()
for an easy access to this limit.
The number of elements in the map is limited to std::numeric_limits<IndexSizeT>::max()
. That is 4 294 967 296 elements, but can be raised with the IndexSizeT
template parameter. See max_size()
for an easy access to this limit.
Iterators invalidation:
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::char_type = typename ht::char_type |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::const_iterator = typename ht::const_iterator |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::hasher = typename ht::hasher |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::index_size_type = typename ht::index_size_type |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::iterator = typename ht::iterator |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::key_equal = typename ht::key_equal |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::key_size_type = typename ht::key_size_type |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::mapped_type = T |
using tsl::array_map< CharT, T, Hash, KeyEqual, StoreNullTerminator, KeySizeT, IndexSizeT, GrowthPolicy >::size_type = typename ht::size_type |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inlinestatic |
Deserialize a previouly serialized map through the deserializer
parameter.
The deserializer
parameter must be a function object that supports the following calls:
template<typename U> U operator()();
where the types std::uint64_t
, float
and T
must be supported for U.void operator()(CharT* value_out, std::size_t value_size);
If the deserialized hash map type is hash compatible with the serialized map, the deserialization process can be sped up by setting hash_compatible
to true. To be hash compatible, the Hash (take care of the 32-bits vs 64 bits), KeyEqual, GrowthPolicy, StoreNullTerminator, KeySizeT and IndexSizeT must behave the same than the one used on the serialazed map. Otherwise the behaviour is undefined with hash_compatible
sets to true, .
The behaviour is undefined if the type CharT
and T
of the array_map
are not the same as the types used during serialization.
The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, ...) of the types it deserializes in the hands of the Deserializer
function object if compatibilty is required.
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
|
inline |
Erase has an amortized O(1) runtime complexity, but even if it removes the key immediatly, it doesn't do the same for the associated value T.
T will only be removed when the ratio between the size of the map and the size of the map + the number of deleted values still stored is low enough.
To force the deletion you can call shrink_to_fit.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Return the const_iterator it
as an iterator
.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Serialize the map through the serializer
parameter.
The serializer
parameter must be a function object that supports the following calls:
void operator()(const U& value);
where the types std::uint64_t
, float
and T
must be supported for U.void operator()(const CharT* value, std::size_t value_size);
The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, ...) of the types it serializes in the hands of the Serializer
function object if compatibilty is required.
|
inline |
|
inlinenoexcept |
|
inline |
|
friend |
|
friend |
|
friend |
|
static |