28 #ifndef GUM_HASH_FUNC_H 29 #define GUM_HASH_FUNC_H 34 #include <type_traits> 37 #include <agrum/agrum.h> 38 #include <agrum/tools/core/refPtr.h> 76 =
sizeof(
Size) == 4 ?
Size(2654435769UL) :
Size(11400714819323198486UL);
78 =
sizeof(
Size) == 4 ?
Size(3373259426UL) :
Size(14488038916154245684UL);
80 =
sizeof(
Size) == 4 ?
Size(4294967295UL) :
Size(18446744073709551615UL);
147 template <
typename Key >
165 void resize(
const Size new_size);
240 template <
typename Key >
272 template <
typename Key >
311 template <
typename Key >
343 template <
typename Key >
379 template <
typename Key >
402 template <
typename Key >
406 template <
typename... >
407 struct HashFuncConditionalType;
410 template <
typename Key >
411 struct HashFuncConditionalType< Key > {
416 template <
typename KEY_TYPE,
typename TYPE >
417 struct HashFuncConditionalType< KEY_TYPE, TYPE > {
418 using type =
typename std::
419 conditional< std::is_same< KEY_TYPE, TYPE >::value,
dummyHash< KEY_TYPE >, KEY_TYPE >::type;
443 template <
typename KEY_TYPE,
typename FIRST_TYPE,
typename... OTHER_TYPES >
444 struct HashFuncConditionalType< KEY_TYPE, FIRST_TYPE, OTHER_TYPES... > {
445 using type =
typename std::conditional<
446 std::is_same< KEY_TYPE, FIRST_TYPE >::value,
448 typename HashFuncConditionalType< KEY_TYPE, OTHER_TYPES... >::type >::type;
467 template <
typename key >
478 template <
typename Key1,
typename Key2 >
572 template <
typename Type >
656 template <
typename Type >
678 #ifndef GUM_NO_INLINE 679 # include <agrum/tools/core/hashFunc_inl.h> 683 #include <agrum/tools/core/hashFunc_tpl.h>
HashFuncSmallCastKey()
Class constructor.
static constexpr Size offset
HashFuncMediumCastKey()
Class constructor.
Generic hash functions for keys castable as Size and whose size is precisely twice that of Size...
static constexpr Size gold
static constexpr Size small_key_mask_
An additional mask to ensure that keys with fewer bits than Size are cast correctly.
Size hash_size_
The size of the hash table.
INLINE void emplace(Args &&... args)
HashFuncSmallKey()
Class constructor.
static constexpr Size mask
Size size() const
Returns the hash table size as known by the hash function.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
friend class HashFunc
A friend for hashing quickly ref pointers.
static Size castToSize(const Key &key)
Returns the value of a key as a Size.
Generic hash functions for keys castable as Size whose size is either smaller than Size...
unsigned int right_shift_
performing y = x >> right_shift_ guarantees that y is a slot index of the hash table ...
Generic hash functions for keys castable as Size and whose size is precisely that of Size...
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...
Size hash_mask_
performing y = x & hash_mask_ guarantees that y is a slot index of the hash table ...
static Size castToSize(const Key &key)
Returns the value of a key as a Size.
static Size castToSize(const Key &key)
Cast key to the expected type.
HashFuncLargeCastKey()
Class constructor.
Useful constants for hash functions.
Generic hash functions for numeric keys smaller than or equal to Size.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
virtual Size operator()(const std::pair< Key1, Key2 > &key) const override final
Computes the hashed value of a key.
virtual Size operator()(const Key &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.
All hash functions should inherit from this class.
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 strictly smaller than that of Size...
virtual Size operator()(const Key &key) const =0
Computes the hashed value of a key.
virtual Size operator()(const Key &key) const override final
Computes the hashed value of a key.
static Size castToSize(const Key &key)
Returns the value of a key as a Size.