aGrUM  0.16.0
gum::HashFuncLargeCastKey< Key > Class Template Reference

Generic hash functions for keys castable as Size and whose size is precisely twice that of Size. More...

#include <agrum/core/hashFunc.h>

+ Inheritance diagram for gum::HashFuncLargeCastKey< Key >:
+ Collaboration diagram for gum::HashFuncLargeCastKey< Key >:

Public Member Functions

 HashFuncLargeCastKey ()
 Class constructor. More...
 
virtual Size operator() (const Key &key) const override final
 Computes the hashed value of a key. More...
 
void resize (const Size new_size)
 Update the hash function to take into account a resize of the hash table. More...
 
Size size () const
 Returns the hash table size as known by the hash function. More...
 

Static Public Member Functions

static Size castToSize (const Key &key)
 Cast key to the expected type. More...
 

Protected Attributes

Size _hash_size {Size(0)}
 The size of the hash table. More...
 
unsigned int _hash_log2_size {0}
 Log of the number of slots of the hash table in base 2. More...
 
Size _hash_mask {Size(0)}
 performing y = x & _hash_mask guarantees that y is a slot index of the hash table More...
 
unsigned int _right_shift {0}
 performing y = x >> _right_shift guarantees that y is a slot index of the hash table More...
 

Detailed Description

template<typename Key>
class gum::HashFuncLargeCastKey< Key >

Generic hash functions for keys castable as Size and whose size is precisely twice that of Size.

Template Parameters
KeyThe type hashed by this hash function.

Definition at line 346 of file hashFunc.h.

Constructor & Destructor Documentation

◆ HashFuncLargeCastKey()

template<typename Key >
gum::HashFuncLargeCastKey< Key >::HashFuncLargeCastKey ( )

Class constructor.

Member Function Documentation

◆ castToSize()

template<typename Key >
static Size gum::HashFuncLargeCastKey< Key >::castToSize ( const Key &  key)
static

Cast key to the expected type.

Parameters
keyThe key to cast.
Returns
Returns the cast key to the expected type.

◆ operator()()

template<typename Key >
virtual Size gum::HashFuncLargeCastKey< Key >::operator() ( const Key &  key) const
finaloverridevirtual

Computes the hashed value of a key.

Parameters
keyThe key to compute the hashed value.
Returns
Returns the hashed value of a key.

Implements gum::HashFuncBase< Key >.

◆ resize()

template<typename Key>
void gum::HashFuncBase< Key >::resize ( const Size  new_size)
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.

Parameters
new_sizeThe hashtable's size wished by the user. Actually, a hashtable of size n is an array of n lists.
Exceptions
SizeErrorRaised if s is too small.

◆ size()

template<typename Key>
Size gum::HashFuncBase< Key >::size ( ) const
inherited

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.

Member Data Documentation

◆ _hash_log2_size

template<typename Key>
unsigned int gum::HashFuncBase< Key >::_hash_log2_size {0}
protectedinherited

Log of the number of slots of the hash table in base 2.

Definition at line 204 of file hashFunc.h.

◆ _hash_mask

template<typename Key>
Size gum::HashFuncBase< Key >::_hash_mask {Size(0)}
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 215 of file hashFunc.h.

◆ _hash_size

template<typename Key>
Size gum::HashFuncBase< Key >::_hash_size {Size(0)}
protectedinherited

The size of the hash table.

Definition at line 201 of file hashFunc.h.

◆ _right_shift

template<typename Key>
unsigned int gum::HashFuncBase< Key >::_right_shift {0}
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 226 of file hashFunc.h.


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