Generic hash functions for keys castable as Size and whose size is strictly smaller than that of Size.
More...
#include <agrum/tools/core/hashFunc.h>
|
static constexpr Size | small_key_mask_ {(Size(1) << (8 * sizeof(Key))) - Size(1)} |
| An additional mask to ensure that keys with fewer bits than Size are cast correctly. More...
|
|
template<typename Key>
class gum::HashFuncSmallCastKey< Key >
Generic hash functions for keys castable as Size and whose size is strictly smaller than that of Size.
- Template Parameters
-
Key | The type hashed by this hash function. |
Definition at line 273 of file hashFunc.h.
◆ HashFuncSmallCastKey()
◆ castToSize()
Returns the value of a key as a Size.
- Parameters
-
key | The value to return as a Size. |
- Returns
- Returns the value of a key as a Size.
◆ operator()()
Computes the hashed value of a key.
- Parameters
-
key | The key to compute the hashed value. |
- Returns
- Returns the hashed value of a key.
Implements gum::HashFuncBase< Key >.
◆ resize()
Update the hash function to take into account a resize of the hash table.
When the user wishes to resize the gum::HashTable so that the array is of size s, the gum::HashTable resizes itself to the smallest power of 2 greater than or equal to s. This new size is computed by function gum::HashFuncBase::resize(gum::Size). Hence, s should be the size of the array of lists, not the number of elements stored into the gum::HashTable.
- Parameters
-
new_size | The hashtable's size wished by the user. Actually, a hashtable of size n is an array of n lists. |
- Exceptions
-
◆ size()
Returns the hash table size as known by the hash function.
- Returns
- Returns the size of the hash table, i.e., the number of slots (lists) it contains.
◆ hash_log2_size_
Log of the number of slots of the hash table in base 2.
Definition at line 203 of file hashFunc.h.
◆ hash_mask_
performing y = x & hash_mask_ guarantees that y is a slot index of the hash table
To transform a Size x into a slot index of the hash table, you can either use x & hash_mask_ or x >> right_shift_ depending on whether you want to exploit the least significant bits of x (&) or the most significant one (>>).
Definition at line 214 of file hashFunc.h.
◆ hash_size_
The size of the hash table.
Definition at line 200 of file hashFunc.h.
◆ right_shift_
performing y = x >> right_shift_ guarantees that y is a slot index of the hash table
To transform a Size x into a slot index of the hash table, you can either use x & hash_mask_ or x >> right_shift_ depending on whether you want to exploit the least significant bits of x (&) or the most significant one (>>).
Definition at line 225 of file hashFunc.h.
◆ small_key_mask_
An additional mask to ensure that keys with fewer bits than Size are cast correctly.
Definition at line 299 of file hashFunc.h.
The documentation for this class was generated from the following file: