|
ADS
Algorithms and Data Structures
|
a DICTIONARY on \( d \) tables of lists, a key in the shortest of its \( d \) lists More...
#include <ADS/dictionary/UniversalHashing.h>
Classes | |
| class | const_iterator |
| the iterator on the pairs, table after table and list after list More... | |
Public types | |
| using | Key = K |
| the type of the keys | |
| using | Value = V |
| the type of the values | |
| using | value_type = std::pair< K , V > |
| the type of the items, for the standard library | |
| using | key_type = K |
| the type of the keys | |
| using | mapped_type = V |
| the type of the values | |
| using | size_type = std::size_t |
| the type of the sizes | |
| using | difference_type = std::ptrdiff_t |
| the type of the distances between two iterators | |
| using | reference = PairRef< const K & , const V & > |
| a reference to an item | |
| using | const_reference = reference |
| a constant reference to an item | |
| using | iterator = const_iterator |
| the iterator on the items | |
Public member functions | |
| DLeftHashTable (std::size_t m, int d, std::uint64_t seed=1, H h=H()) | |
| \( d \) tables of \( w \) lists each, \( w = \max\{ 1 , \lfloor m / d \rfloor \} \) | |
| std::optional< V > | lookup (const K &k) const |
| the value of the key \( k \), or nothing, from its \( d \) lists | |
| void | insert (const K &k, const V &v) |
| associates the value \( v \) to the key \( k \) | |
| void | remove (const K &k) |
| removes the key \( k \), if it is there, from its list | |
| bool | contains (const K &k) const |
| true if the key \( k \) is there | |
| std::size_t | size (void) const |
| the number of keys | |
| std::size_t | maxLoad (void) const |
| the length of the longest list | |
| int | tables (void) const |
| the number of tables | |
| const_iterator | begin (void) const |
| the iterator on the first item | |
| const_iterator | end (void) const |
| the iterator past the last item | |
| const_iterator | cbegin (void) const |
| the constant iterator on the first item | |
| const_iterator | cend (void) const |
| the constant iterator past the last item | |
a DICTIONARY on \( d \) tables of lists, a key in the shortest of its \( d \) lists
| using ADS::DLeftHashTable< K, V, H >::const_reference = reference |
a constant reference to an item
| using ADS::DLeftHashTable< K, V, H >::difference_type = std::ptrdiff_t |
the type of the distances between two iterators
| using ADS::DLeftHashTable< K, V, H >::iterator = const_iterator |
the iterator on the items
| using ADS::DLeftHashTable< K, V, H >::Key = K |
the type of the keys
| using ADS::DLeftHashTable< K, V, H >::key_type = K |
the type of the keys
| using ADS::DLeftHashTable< K, V, H >::mapped_type = V |
the type of the values
| using ADS::DLeftHashTable< K, V, H >::reference = PairRef< const K & , const V & > |
a reference to an item
| using ADS::DLeftHashTable< K, V, H >::size_type = std::size_t |
the type of the sizes
| using ADS::DLeftHashTable< K, V, H >::Value = V |
the type of the values
| using ADS::DLeftHashTable< K, V, H >::value_type = std::pair< K , V > |
the type of the items, for the standard library
| ADS::DLeftHashTable< K, V, H >::DLeftHashTable | ( | std::size_t | m, |
| int | d, | ||
| std::uint64_t | seed = 1, | ||
| H | h = H() ) |
\( d \) tables of \( w \) lists each, \( w = \max\{ 1 , \lfloor m / d \rfloor \} \)
|
inlinenodiscard |
the iterator on the first item
|
inlinenodiscard |
the constant iterator on the first item
|
inlinenodiscard |
the constant iterator past the last item
|
nodiscard |
true if the key \( k \) is there
|
inlinenodiscard |
the iterator past the last item
| void ADS::DLeftHashTable< K, V, H >::insert | ( | const K & | k, |
| const V & | v ) |
associates the value \( v \) to the key \( k \)
In pseudocode (the d-left hashing of Vöcking, beyond the book), \( L_i( k ) \) the list of \( k \) in the table \( i \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{insert}( k , v ) \cr 2 & \quad \textbf{if}\ k \text{ is in some } L_i( k )\ \textbf{then} \ \text{give it the value } v;\ \textbf{return} \cr 3 & \quad j \gets 0 \cr 4 & \quad \textbf{for}\ i \gets 1\ \textbf{to}\ d - 1\ \textbf{do} \ \textbf{if}\ |L_i( k )| < |L_j( k )|\ \textbf{then}\ j \gets i \cr 5 & \quad \text{append } ( k , v ) \text{ to } L_j( k )\quad \triangleright\ \text{the shortest, the leftmost on a tie} \end{array}} \]
|
nodiscard |
the value of the key \( k \), or nothing, from its \( d \) lists
|
nodiscard |
the length of the longest list
| void ADS::DLeftHashTable< K, V, H >::remove | ( | const K & | k | ) |
removes the key \( k \), if it is there, from its list
|
nodiscard |
the number of keys
|
nodiscard |
the number of tables