48#ifndef GUM_HASH_FUNC_H
49#define GUM_HASH_FUNC_H
98 =
sizeof(
Size) == 4 ?
Size(2654435769UL) :
Size(11400714819323198486UL);
100 =
sizeof(
Size) == 4 ?
Size(3373259426UL) :
Size(14488038916154245684UL);
102 =
sizeof(
Size) == 4 ?
Size(4294967295UL) :
Size(18446744073709551615UL);
168 template <
typename Key >
260 template <
typename Key >
296 template <
typename Key >
334 template <
typename Key >
365 template <
typename Key >
400 template <
typename Key >
403 using type =
typename std::conditional<
404 sizeof(Key) <=
sizeof(
Size) && std::is_integral< Key >::value,
406 typename std::conditional<
407 sizeof(Key) <
sizeof(
Size),
409 typename std::conditional<
sizeof(Key) ==
sizeof(
Size),
411 typename std::conditional<
sizeof(Key) == 2 *
sizeof(
Size),
422 template <
typename Key >
426 template <
typename... >
430 template <
typename Key >
436 template <
typename KEY_TYPE,
typename TYPE >
463 template <
typename KEY_TYPE,
typename FIRST_TYPE,
typename... OTHER_TYPES >
465 using type =
typename std::conditional<
466 std::is_same< KEY_TYPE, FIRST_TYPE >::value,
486 template <
typename key >
497 template <
typename Key1,
typename Key2 >
512 virtual Size operator()(
const std::pair< Key1, Key2 >& key)
const override final;
590 template <
typename Type >
661 template <
typename OTHER_KEY >
671 template <
typename Type >
All hash functions should inherit from this class.
virtual Size operator()(const Key &key) const =0
Computes the hashed value of a key.
unsigned int right_shift_
performing y = x >> right_shift_ guarantees that y is a slot index of the hash table
Size size() const
Returns the hash table size as known by the hash function.
Size hash_size_
The size of the hash table.
Size hash_mask_
performing y = x & hash_mask_ guarantees that y is a slot index of the hash table
void resize(const Size new_size)
Update the hash function to take into account a resize of the hash table.
unsigned int hash_log2_size_
Log of the number of slots of the hash table in base 2.
Generic hash functions for keys castable as Size and whose size is precisely twice that of Size.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
HashFuncLargeCastKey()
Class constructor.
static Size castToSize(const Key &key)
Cast key to the expected type.
Generic hash functions for keys castable as Size and whose size is precisely that of Size.
static Size castToSize(const Key &key)
Returns the value of a key as a Size.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
HashFuncMediumCastKey()
Class constructor.
Generic hash functions for keys castable as Size and whose size is strictly smaller than that of Size...
HashFuncSmallCastKey()
Class constructor.
static Size castToSize(const Key &key)
Returns the value of a key as a Size.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
static constexpr Size small_key_mask_
An additional mask to ensure that keys with fewer bits than Size are cast correctly.
Generic hash functions for numeric keys smaller than or equal to Size.
static Size castToSize(const Key &key)
Returns the value of a key as a Size.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
HashFuncSmallKey()
Class constructor.
static Size castToSize(const Debug &key)
Returns the value of a key as a Size.
virtual Size operator()(const Debug &key) const override final
Computes the hashed value of a key.
virtual Size operator()(const RefPtr< Type > &key) const override final
Computes the hashed value of a key.
static Size castToSize(const RefPtr< Type > &key)
Returns the value of a key as a Size.
virtual Size operator()(const std::pair< Key1, Key2 > &key) const override final
Computes the hashed value of a key.
static Size castToSize(const std::pair< Key1, Key2 > &key)
Returns the value of a key as a Size.
virtual Size operator()(const std::string &key) const override final
Computes the hashed value of a key.
static Size castToSize(const std::string &key)
Returns the value of a key as a Size.
virtual Size operator()(const std::vector< Idx > &key) const override final
Computes the hashed value of a key.
static Size castToSize(const std::vector< Idx > &key)
Returns the value of a key as a Size.
This class should be useless as only its specializations should be used.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
unsigned int _hashTableLog2_(const Size nb)
Returns the size in bits - 1 necessary to store the smallest power of 2 greater than or equal to nb.
Inlined implementation of the basic hash functions.
Template implementation of the basic hash functions.
gum is the global namespace for all aGrUM entities
Class providing aGrUM's "smart" pointers.
Generic hash functions for keys castable as Size whose size is either smaller than Size,...
typename std::conditional< sizeof(Key)<=sizeof(Size) &&std::is_integral< Key >::value, HashFuncSmallKey< Key >, typename std::conditional< sizeof(Key)< sizeof(Size), HashFuncSmallCastKey< Key >, typename std::conditional< sizeof(Key)==sizeof(Size), HashFuncMediumCastKey< Key >, typename std::conditional< sizeof(Key)==2 *sizeof(Size), HashFuncLargeCastKey< Key >, void >::type >::type >::type >:: type type
The type used by this class.
typename std::conditional< std::is_same< KEY_TYPE, FIRST_TYPE >::value, dummyHash< KEY_TYPE >, typename HashFuncConditionalType< KEY_TYPE, OTHER_TYPES... >::type >::type type
typename std:: conditional< std::is_same< KEY_TYPE, TYPE >::value, dummyHash< KEY_TYPE >, KEY_TYPE >::type type
This class enables to safely define hash functions for types that may or may not already has defined ...
Useful constants for hash functions.
static constexpr Size mask
static constexpr Size offset
static constexpr Size gold