![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Hash function for gum::Instantiation. More...
#include <instantiation.h>
Public Member Functions | |
| virtual Size | operator() (const Instantiation &key) const override final |
| Computes the hashed value of a key. | |
| void | resize (const Size new_size) |
| Update the hash function to take into account a resize of the hash table. | |
| Size | size () const |
| Returns the hash table size as known by the hash function. | |
Static Public Member Functions | |
| static Size | castToSize (const Instantiation &key) |
| Returns the value of a key as a Size. | |
Protected Attributes | |
| Size | hash_size_ |
| The size of the hash table. | |
| unsigned int | hash_log2_size_ |
| Log of the number of slots of the hash table in base 2. | |
| Size | hash_mask_ |
| performing y = x & hash_mask_ guarantees that y is a slot index of the hash table | |
| unsigned int | right_shift_ |
| performing y = x >> right_shift_ guarantees that y is a slot index of the hash table | |
Hash function for gum::Instantiation.
Definition at line 1247 of file instantiation.h.
|
static |
Returns the value of a key as a Size.
returns a hashed key for hash tables the keys of which are represented by vectors of Idx
| key | The value to return as a Size. |
Definition at line 774 of file instantiation_inl.h.
References castToSize(), gum::Instantiation::val(), and gum::Instantiation::variablesSequence().
Referenced by castToSize(), and operator()().
|
finaloverridevirtual |
Computes the hashed value of a key.
returns a hashed key for hash tables the keys of which are represented by vectors of Idx
| key | The key to compute the hashed value. |
Implements gum::HashFuncBase< Instantiation >.
Definition at line 785 of file instantiation_inl.h.
References castToSize(), gum::HashFuncBase< Instantiation >::hash_mask_, and operator()().
Referenced by operator()().
|
inherited |
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.
| new_size | The hashtable's size wished by the user. Actually, a hashtable of size n is an array of n lists. |
| SizeError | Raised if s is too small. |
|
inherited |
Returns the hash table size as known by the hash function.
|
protectedinherited |
Log of the number of slots of the hash table in base 2.
Definition at line 224 of file hashFunc.h.
|
protectedinherited |
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 235 of file hashFunc.h.
Referenced by gum::HashFunc< Instantiation >::operator()().
|
protectedinherited |
|
protectedinherited |
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 246 of file hashFunc.h.