27 #ifndef GUM_HASH_FUNC_H 28 #define GUM_HASH_FUNC_H 33 #include <type_traits> 75 sizeof(
Size) == 4 ?
Size(2654435769UL) :
Size(11400714819323198486UL);
77 sizeof(
Size) == 4 ?
Size(3373259426UL) :
Size(14488038916154245684UL);
79 sizeof(
Size) == 4 ?
Size(4294967295UL) :
Size(18446744073709551615UL);
146 template <
typename Key >
164 void resize(
const Size new_size);
195 virtual Size operator()(
const Key& key)
const = 0;
202 unsigned int _hash_log2_size{0};
224 unsigned int _right_shift{0};
239 template <
typename Key >
252 static Size castToSize(
const Key& key);
259 virtual Size operator()(
const Key& key)
const override final;
271 template <
typename Key >
284 static Size castToSize(
const Key& key);
291 virtual Size operator()(
const Key& key)
const override final;
298 static constexpr
Size _small_key_mask{(
Size(1) << (8 *
sizeof(Key)))
311 template <
typename Key >
324 static Size castToSize(
const Key& key);
331 virtual Size operator()(
const Key& key)
const override final;
343 template <
typename Key >
356 static Size castToSize(
const Key& key);
363 virtual Size operator()(
const Key& key)
const override final;
379 template <
typename Key >
382 using type =
typename std::conditional<
383 sizeof(Key) <=
sizeof(
Size) && std::is_integral< Key >::value,
385 typename std::conditional<
386 sizeof(Key) <
sizeof(
Size),
388 typename std::conditional<
389 sizeof(Key) ==
sizeof(
Size),
391 typename std::conditional<
sizeof(Key) == 2 *
sizeof(
Size),
402 template <
typename Key >
406 template <
typename... >
410 template <
typename Key >
416 template <
typename KEY_TYPE,
typename TYPE >
418 using type =
typename std::conditional< std::is_same< KEY_TYPE, TYPE >::value,
444 template <
typename KEY_TYPE,
typename FIRST_TYPE,
typename... OTHER_TYPES >
446 using type =
typename std::conditional<
447 std::is_same< KEY_TYPE, FIRST_TYPE >::value,
468 template <
typename key >
479 template <
typename Key1,
typename Key2 >
488 static Size castToSize(
const std::pair< Key1, Key2 >& key);
496 operator()(
const std::pair< Key1, Key2 >& key)
const override final;
578 template <
typename Type >
594 static Size castToSize(
const std::string& key);
601 virtual Size operator()(
const std::string& key)
const override final;
619 static Size castToSize(
const std::vector< Idx >& key);
626 virtual Size operator()(
const std::vector< Idx >& key)
const override final;
643 static Size castToSize(
const Debug& key);
650 virtual Size operator()(
const Debug& key)
const override final;
652 template <
typename OTHER_KEY >
663 template <
typename Type >
685 #ifndef GUM_NO_INLINE
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.
static constexpr Size offset
Generic hash functions for keys castable as Size and whose size is precisely twice that of Size...
static constexpr Size gold
typename std::conditional< std::is_same< KEY_TYPE, FIRST_TYPE >::value, dummyHash< KEY_TYPE >, typename HashFuncConditionalType< KEY_TYPE, OTHER_TYPES... >::type >::type type
static constexpr Size mask
Class providing aGrUM's "smart" pointers.
Class template representing hashing function of LpCol.
gum is the global namespace for all aGrUM entities
Generic hash functions for keys castable as Size whose size is either smaller than Size...
Generic hash functions for keys castable as Size and whose size is precisely that of Size...
Smart pointersaGrUM's smart pointers keep track of the number of times the value they point to is ref...
Template implementation of the basic hash functions.
Useful constants for hash functions.
Generic hash functions for numeric keys smaller than or equal to Size.
typename std::conditional< std::is_same< KEY_TYPE, TYPE >::value, dummyHash< KEY_TYPE >, KEY_TYPE >::type type
All hash functions should inherit from this class.
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.
This class enables to safely define hash functions for types that may or may not already has defined ...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Generic hash functions for keys castable as Size and whose size is strictly smaller than that of Size...