libhatchet
Loading...
Searching...
No Matches
hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ > Class Template Reference

#include <hxhash_table.hpp>

Classes

class  const_iterator
class  iterator

Public Types

using node_t = node_t_
using key_t = typename node_t_::key_t

Public Member Functions

 hxhash_table (deleter_t_ deleter_=deleter_t_())
 ~hxhash_table (void)
template<hxrange_concept_ range_t_, hxenable_if_t<!hxis_lvalue_reference< range_t_ >(), int > = 0>
void add_range (range_t_ &&range_) noexcept
template<typename self_t_, typename callable_t_>
auto and_then (this self_t_ &&self_, const key_t &key_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< node_t_ & >())))>
template<typename self_t_, typename callable_t_>
auto and_then (this self_t_ &&self_, const_iterator it_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< const node_t_ & >())))>
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
const deleter_t_ & deleter (void) const
deleter_t_ & deleter (void)
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
hxptr< node_t_, deleter_t_ > extract (const const_iterator &it_) noexcept
const_iterator find (const typename node_t_::key_t &key_, const const_iterator &previous_=const_iterator()) const
iterator find (const typename node_t_::key_t &key_, const const_iterator &previous_=const_iterator())
bool has_value (const key_t &key_) const
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
template<typename self_t_, typename callable_t_>
auto or_else (this self_t_ &&self_, const key_t &key_, callable_t_ &&callable_) -> decltype(self_.end())
template<typename self_t_, typename callable_t_>
auto or_else (this self_t_ &&self_, const_iterator it_, callable_t_ &&callable_) -> decltype(self_.end())
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<typename self_t_>
auto value_or (this self_t_ &&self_, const key_t &key_, const node_t_ *default_value_) -> decltype(self_.end())
template<typename self_t_>
auto value_or (this self_t_ &&self_, const_iterator it_, const node_t_ *default_value_) -> decltype(self_.end())

Detailed Description

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 derived from hxhash_node_base and using key K will work as long as K has an operator== or an hxkey_equal_t specialization.

class T : public hxhash_node_base {
using key_t = K; // Tell the hash table what key to use.
const key_t& hash_key() const; // Returns key constructed with.
};
hxhash_node_base - Intrusive hash-chain node base.
Definition hxhash_table.hpp:47
typename node_t_::key_t key_t
Definition hxhash_table.hpp:226

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_t specialization and will require an hxkey_hash_t specialization.

They might be used as follows:

// An unordered set of allowed or blocked internet addresses.
// A fixed-size unordered map of material identifiers to material
// properties. Missing materials can be safely resolved.
using material_db_t = hxhash_table<hxhash_table_map_node<material_id_t,
material_t>, hxdefault_delete, true, 1024>;
hxdefault_delete - A callable that deletes objects of type T using hxdelete.
Definition hxmemory_manager.h:265
hxhash_table_map_node - Base class for unordered map entries.
Definition hxhash_table.hpp:110
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 configure hash bits dynamically.

Member Typedef Documentation

◆ key_t

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
using hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::key_t = typename node_t_::key_t

◆ node_t

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
using hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::node_t = node_t_

Constructor & Destructor Documentation

◆ hxhash_table()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::hxhash_table ( deleter_t_ deleter_ = deleter_t_())
explicit

Constructs an empty hash table with a capacity of 2^table_size_bits and an optional deleter instance.

  • deleter : Callable with signature bool deleter(node_t_*).

◆ ~hxhash_table()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::~hxhash_table ( void )
inline

Destructs the hash table and deletes all resources.

Member Function Documentation

◆ add_range()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<hxrange_concept_ range_t_, hxenable_if_t<!hxis_lvalue_reference< range_t_ >(), int > = 0>
void hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::add_range ( range_t_ && range_)
noexcept

Links each node_t from a temporary range into this hash table by address, exactly as insert(node_t*) would.

The range's nodes are threaded into the table in place and are not copied or allocated, so range must own storage it is relinquishing to the table.

  • range : The range of nodes to link into the table.

◆ and_then() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_, typename callable_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::and_then ( this self_t_ && self_,
const key_t & key_,
callable_t_ && callable_ )->hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< node_t_ & >())))>

Returns the result of calling callable with the first node matching key, otherwise returns hxnil.

Use and_then to return hxptr, hxref or hxexpected.

  • key : The key to search for.
  • callable : The function to call with the found node.

◆ and_then() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_, typename callable_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::and_then ( this self_t_ && self_,
const_iterator it_,
callable_t_ && callable_ )->hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< constnode_t_ & >())))>

Iterator overload of and_then.

  • it : A const iterator to a node or end().
  • callable : The function to call with the node.

◆ begin() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::begin ( void )
inline

Returns an iterator pointing to the beginning of the hash table.

◆ begin() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const_iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::begin ( void ) const
inline

Returns a const iterator pointing to the beginning of the hash table.

◆ bucket_count()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::bucket_count ( void ) const
inline

Returns the number of buckets in the hash table.

◆ cbegin()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const_iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::cbegin ( void ) const
inline

Returns a const iterator pointing to the beginning of the hash table.

◆ cend()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const_iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::cend ( void ) const
inline

Returns a const iterator pointing to the end of the hash table.

◆ clear() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename deleter_u_>
void hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::clear ( deleter_u_ && deleter_)
noexcept

Removes all nodes and if deleter is true then calls deleter() on every node.

  • deleter : Callable with signature bool deleter(node_t_*).

◆ clear() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
void hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::clear ( void )
inlinenoexcept

Removes all nodes and calls the stored deleter on every node.

◆ count()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::count ( const typename node_t_::key_t & key_) const

Counts the number of nodes with the given key.

  • key : The key to count occurrences of in the hash table.

◆ deleter() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
deleter_t_ & hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::deleter ( void )

◆ deleter() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const deleter_t_ & hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::deleter ( void ) const

Returns a const reference to the stored deleter.

◆ emplace()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<hxsystem_allocator_t allocator_ = hxsystem_allocator_current, hxalignment_t align_ = hxalignment, bool multi_ = multi_t_, class... args_t_>
hxenable_if_t< multi_, iterator > hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::emplace ( args_t_ &&... args_)
noexcept

emplace - Returns an iterator to the node constructed with hxnew.

The table must have multi_t set to true.

  • allocator : The memory manager ID to use for allocation. Defaults to hxsystem_allocator_current.
  • align : Alignment to use when allocating new pointers. Defaults to hxalignment.
  • args : Arguments forwarded to the node constructor.

◆ empty()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
bool hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::empty ( void ) const
inline

Checks if the hash table is empty.

◆ end() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::end ( void )
inline

Returns an iterator pointing to the end of the hash table.

◆ end() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const_iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::end ( void ) const
inline

Returns a const iterator pointing to the end of the hash table.

◆ erase() [1/3]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::erase ( const const_iterator & it_)
noexcept

Removes and calls the stored deleter on the node_t referenced by it.

Returns an iterator to the node following it, or end().

  • it : A valid iterator into this hash table.

◆ erase() [2/3]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::erase ( const typename node_t_::key_t & key_)
noexcept

Removes and calls the stored deleter on nodes with an equivalent key.

  • key : The key to search for and remove from the hash table.

◆ erase() [3/3]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename deleter_u_>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::erase ( const typename node_t_::key_t & key_,
deleter_u_ && deleter_ )
noexcept

Releases all nodes matching key and calls deleter on every node.

Returns the number of nodes released. Deleter can be functions with signature void deleter(node_t*) and callables supporting operator()(node_t*) and with an operator bool. e.g., a free list or a null pointer.

  • key : The key to search for and remove from the hash table.
  • deleter : Callable with signature bool deleter(node_t_*).

◆ extract() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxptr< node_t_, deleter_t_ > hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::extract ( const const_iterator & it_)
noexcept

Removes the node_t referenced by it and returns an hxptr owning it.

  • it : A valid iterator into this hash table.

◆ extract() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxptr< node_t_, deleter_t_ > hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::extract ( const typename node_t_::key_t & key_)
noexcept

extract - Returns an hxptr owning the first node_t with the given key, or an empty hxptr if no matching node is found.

  • key : The key to search for and remove from the hash table.

◆ find() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::find ( const typename node_t_::key_t & key_,
const const_iterator & previous_ = const_iterator() )

◆ find() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const_iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::find ( const typename node_t_::key_t & key_,
const const_iterator & previous_ = const_iterator() ) const

Returns an iterator to a node_t matching key, or end() if none exists.

If previous is not end() it must be an iterator previously returned from find() with the same key that has not been removed. Then find() will return a subsequent node if any.

  • key : The key to search for in the hash table.
  • previous : A previously found iterator with the same key, or end().

◆ has_value()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
bool hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::has_value ( const key_t & key_) const

Returns true if a node matching key exists.

  • key : The key to search for.

◆ insert() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename deleter_u_>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::insert ( hxptr< node_t_, deleter_u_ > && ptr_)
noexcept

insert - Returns an iterator to the inserted node.

When multi_t is false and a node with an equal key already exists, returns an iterator to the existing node and ptr is destroyed, invoking its deleter.

  • ptr : The hxptr owning the node to insert.

◆ insert() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
iterator hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::insert ( node_t_ * ptr_)
noexcept

insert - Returns an iterator to the inserted node.

When multi_t is false and a node with an equal key already exists, invokes deleter_t on ptr and returns an iterator to the existing node. ptr must not be null.

  • ptr : The node to insert.

◆ load_factor()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
float hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::load_factor ( void ) const

Returns the average number of nodes per bucket.

◆ load_max()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::load_max ( void ) const

Returns the size of the largest bucket.

◆ or_else() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_, typename callable_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::or_else ( this self_t_ && self_,
const key_t & key_,
callable_t_ && callable_ )->decltype(self_.end())

Returns an iterator to the first node matching key, or the result of calling callable when lookup fails.

  • key : The key to search for.
  • callable : The function to call when lookup fails. Must return an iterator.

◆ or_else() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_, typename callable_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::or_else ( this self_t_ && self_,
const_iterator it_,
callable_t_ && callable_ )->decltype(self_.end())

Iterator overload of or_else.

  • it : An iterator to a node or end().
  • callable : The function to call for end(). Must return an iterator.

◆ release_all()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
void hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::release_all ( void )

Clears the hash table without deleting any nodes.

◆ release_key()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::release_key ( const typename node_t_::key_t & key_)

Removes all nodes matching the given key without deleting them.

  • key : The key to search for and release from the hash table.

◆ replace()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxptr< node_t_, deleter_t_ > hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::replace ( node_t_ * ptr_)
noexcept

replace - Replaces the first node_t matching ptr's key, if any, with ptr and returns an hxptr owning the replaced node.

Returns an empty hxptr and inserts ptr as a new node if no match is found. Avoids the extra lookup an erase followed by insert would require. ptr must not be null.

  • ptr : The node to insert in place of any matching node.

◆ set_size_bits()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
void hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::set_size_bits ( hxhash_t bits_)

Sets the number of hash bits and allocate memory for the table.

(only for dynamic capacity).

  • bits : The number of hash bits to set for the hash table.

◆ size()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::size ( void ) const
inline

Returns the number of elements in the hash table.

◆ try_emplace()

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<hxsystem_allocator_t allocator_ = hxsystem_allocator_current, hxalignment_t align_ = hxalignment, bool multi_ = multi_t_, class... args_t_>
hxenable_if_t<!multi_, iterator > hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::try_emplace ( const typename node_t_::key_t & key_,
args_t_ &&... args_ )
noexcept

try_emplace - Returns an iterator to the node if it was inserted, or an iterator to the existing node if a node with an equal key already exists.

The table must have multi_t set to false.

  • allocator : The memory manager ID to use for allocation. Defaults to hxsystem_allocator_current.
  • align : Alignment to use when allocating new pointers. Defaults to hxalignment.
  • key : The key the node will have once constructed.
  • args : Arguments forwarded to the node constructor.

◆ value_or() [1/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::value_or ( this self_t_ && self_,
const key_t & key_,
const node_t_ * default_value_ )->decltype(self_.end())

Returns an iterator to the first node matching key, or an iterator to default_value when lookup fails.

  • key : The key to search for.
  • default_value : The node to reference when lookup fails.

◆ value_or() [2/2]

template<hxhash_table_concept_ node_t_, typename deleter_t_ = hxdefault_delete, bool multi_t_ = false, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename self_t_>
auto hxhash_table< node_t_, deleter_t_, multi_t_, table_size_bits_ >::value_or ( this self_t_ && self_,
const_iterator it_,
const node_t_ * default_value_ )->decltype(self_.end())

Iterator overload of value_or.

  • it : A const iterator to a node or end().
  • default_value : The node to reference for end().

The documentation for this class was generated from the following file: