|
| | hxhash_table (deleter_t_ deleter_=deleter_t_()) |
| | ~hxhash_table (void) |
| const_iterator | begin (void) const |
| iterator | begin (void) |
| hxsize_t | bucket_count (void) const |
| const_iterator | cbegin (void) const |
| const_iterator | cend (void) const |
| template<typename deleter_u_> |
| void | clear (deleter_u_ &&deleter_) noexcept |
| void | clear (void) noexcept |
| hxsize_t | count (const typename node_t_::key_t &key_) const |
| template<hxsystem_allocator_t allocator_ = hxsystem_allocator_current, hxalignment_t align_ = hxalignment, bool multi_ = multi_t_, class... args_t_> |
| hxenable_if_t< multi_, iterator > | emplace (args_t_ &&... args_) noexcept |
| bool | empty (void) const |
| const_iterator | end (void) const |
| iterator | end (void) |
| template<typename deleter_u_> |
| hxsize_t | erase (const typename node_t_::key_t &key_, deleter_u_ &&deleter_) noexcept |
| hxsize_t | erase (const typename node_t_::key_t &key_) noexcept |
| iterator | erase (const const_iterator &it_) noexcept |
| hxptr< node_t_, deleter_t_ > | extract (const typename node_t_::key_t &key_) noexcept |
| node_t_ * | find (const typename node_t_::key_t &key_, const node_t_ *previous_=0) |
| const node_t_ * | find (const typename node_t_::key_t &key_, const node_t_ *previous_=0) const |
| const deleter_t_ & | deleter (void) const |
| deleter_t_ & | deleter (void) |
| iterator | insert (node_t_ *ptr_) noexcept |
| template<typename deleter_u_> |
| iterator | insert (hxptr< node_t_, deleter_u_ > &&ptr_) noexcept |
| float | load_factor (void) const |
| hxsize_t | load_max (void) const |
| void | release_all (void) |
| hxsize_t | release_key (const typename node_t_::key_t &key_) |
| hxptr< node_t_, deleter_t_ > | replace (node_t_ *ptr_) noexcept |
| void | set_size_bits (hxhash_t bits_) |
| hxsize_t | size (void) const |
| template<hxsystem_allocator_t allocator_ = hxsystem_allocator_current, hxalignment_t align_ = hxalignment, bool multi_ = multi_t_, class... args_t_> |
| hxenable_if_t<!multi_, iterator > | try_emplace (const typename node_t_::key_t &key_, args_t_ &&... args_) noexcept |
template<
hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
class hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >
hxhash_table - A hash table that operates without reallocating memory or copying data.
Each bucket uses an embedded singly-linked list. This design tries to use a sparse table that allocates the maximum amount of memory upfront and then uses a high quality hash instead of relying on linear probing for cache efficiency. Hash tables can act as either an unordered map or an unordered set and support operations that allow for unique or duplicate keys.
Any node T using key K will work as long as it has the following fields and K has an operator== or an hxkey_equal overload.
class T {
T* hash_next() const;
void set_hash_next(node_t_*);
const key_t& hash_key()
const;
};
typename node_t_::key_t key_t
Definition hxhash_table.hpp:184
uint32_t hxhash_t
hxhash_t - Unsigned 32-bit hash value. Expect collisions.
Definition libhatchet.h:212
hxhash_table_set_node and hxhash_table_map_node are provided and recommended as replacements for std::unordered_set and std::unordered_map. Custom key types will require either an operator== or an hxkey_equal overload and will require an hxkey_hash overload.
They might be used as follows:
hxdefault_delete - A callable that deletes objects of type T using hxdelete.
Definition hxmemory_manager.h:254
hxhash_table_map_node - Base class for unordered map entries.
Definition hxhash_table.hpp:93
hxhash_table(deleter_t_ deleter_=deleter_t_())
Constructs an empty hash table with a capacity of 2^table_size_bits and an optional deleter instance.
hx/hxhash_table_nodes.hpp also provides specializations of the hxhash_table::node_t template parameter for integers and strings.
- node_t : Must implement the interface/concept described above.
- deleter_t : A class type invoked as deleter(T*) to free the owned pointer. See also hxdo_not_delete.
- multi_t : When falseand a node with an equal key already exists, insertion into the list will fail when a node with the same key already exists.
- table_size_bits : If non-zero, table_size_bits configures the hash table size to 2^table_size_bits. Otherwise use set_size_bits to to configure hash bits dynamically.