24 #include <type_traits> 50 key = (~key) + (key << 21);
51 key = key ^ (key >> 24);
52 key = key + (key << 3) + (key << 8);
53 key = key ^ (key >> 14);
54 key = key + (key << 2) + (key << 4);
55 key = key ^ (key >> 28);
56 key = key + (key << 31);
69 key *= 4611686016279904257U;
70 key ^= (key >> 28) ^ (key >> 56);
71 key *= 14933078535860113213U;
72 key ^= (key >> 14) ^ (key >> 28) ^ (key >> 42) ^ (key >> 56);
73 key *= 15244667743933553977U;
74 key ^= (key >> 24) ^ (key >> 48);
75 key = (key + 1) * 9223367638806167551U;
84 key = (~key) + (key << 18);
85 key = key ^ (key >> 31);
87 key = key ^ (key >> 11);
88 key = key + (key << 6);
89 key = key ^ (key >> 22);
129 key ^= (key >> 2) ^ (key >> 4) ^ (key >> 6) ^ (key >> 8) ^ (key >> 10) ^
130 (key >> 12) ^ (key >> 14) ^ (key >> 16) ^ (key >> 18) ^ (key >> 20) ^
131 (key >> 22) ^ (key >> 24) ^ (key >> 26) ^ (key >> 28) ^ (key >> 30);
133 key ^= (key >> 9) ^ (key >> 18) ^ (key >> 27);
151 uint32_t hash = FNV_32_HASH_START) noexcept {
153 const signed char*
s =
reinterpret_cast<const signed char*
>(buf);
157 (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
166 uint32_t hash = FNV_32_HASH_START) noexcept {
168 const signed char* char_buf =
reinterpret_cast<const signed char*
>(buf);
170 for (
size_t i = 0;
i < n; ++
i) {
172 (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
181 uint32_t hash = FNV_32_HASH_START) noexcept {
182 return fnv32_buf(str.data(), str.size(), hash);
187 uint64_t hash = FNV_64_HASH_START) noexcept {
189 const signed char*
s =
reinterpret_cast<const signed char*
>(buf);
192 hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) +
193 (hash << 8) + (hash << 40);
202 uint64_t hash = FNV_64_HASH_START) noexcept {
204 const signed char* char_buf =
reinterpret_cast<const signed char*
>(buf);
206 for (
size_t i = 0;
i < n; ++
i) {
207 hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) +
208 (hash << 8) + (hash << 40);
216 uint64_t hash = FNV_64_HASH_START) noexcept {
217 return fnv64_buf(str.data(), str.size(), hash);
223 uint64_t hash = FNVA_64_HASH_START) noexcept {
226 for (
size_t i = 0;
i < n; ++
i) {
228 hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) +
229 (hash << 8) + (hash << 40);
236 uint64_t hash = FNVA_64_HASH_START) noexcept {
237 return fnva64_buf(str.data(), str.size(), hash);
244 #define get16bits(d) folly::loadUnaligned<uint16_t>(d) 248 const unsigned char*
s =
reinterpret_cast<const unsigned char*
>(buf);
253 if (len <= 0 || buf ==
nullptr) {
261 for (; len > 0; len--) {
264 hash = (hash << 16) ^ tmp;
315 template <
typename I>
321 static_assert(
sizeof(I) <= 16,
"Input type is too wide");
322 if (
sizeof(I) <= 4) {
323 auto const i32 =
static_cast<int32_t>(
i);
324 auto const u32 =
static_cast<uint32_t>(i32);
326 }
else if (
sizeof(I) <= 8) {
327 auto const u64 =
static_cast<uint64_t>(
i);
331 auto const hi =
static_cast<uint64_t>(u >>
sizeof(I) * 4);
332 auto const lo =
static_cast<uint64_t>(u);
338 template <
typename F>
343 static_assert(
sizeof(F) <= 8,
"Input type is too wide");
350 memcpy(&u64, &
f,
sizeof(F));
357 template <
class Key,
class Enable =
void>
366 template <
class T,
class... Ts>
407 template <
typename Hasher,
typename Key>
411 template <
typename Hasher,
typename Vo
id =
void>
414 template <
typename Hasher>
417 void_t<typename Hasher::folly_is_avalanching>>
421 template <
typename Hasher,
typename Key>
427 template <
typename H,
typename K>
430 template <
typename K>
442 template <
typename K>
479 #if FOLLY_HAVE_INT128_T 499 return static_cast<size_t>(
503 template <
typename K>
506 template <
typename T>
507 struct hasher<
T, std::enable_if_t<std::is_enum<T>::value>> {
509 return Hash()(
static_cast<std::underlying_type_t<T>
>(key));
513 template <
typename T,
typename K>
515 hasher<
T, std::enable_if_t<std::is_enum<T>::value>>,
518 template <
typename T1,
typename T2>
523 return Hash()(key.first, key.second);
527 template <
typename... Ts>
535 template <
typename T,
typename K>
538 template <
typename T1,
typename T2,
typename... Ts,
typename K>
552 template <
typename T>
554 return std::hash<T>()(
t);
574 const uint64_t kMul = 0x9ddfea08eb382d69ULL;
583 template <
class Hash,
class Value>
588 auto const x = hasher(value);
592 return 3860031 + (seed +
y) * 2779 + (seed *
y * 2);
602 class Hash = std::hash<typename std::iterator_traits<Iter>::value_type>>
611 template <
class Hash,
class Iter>
617 while (first != last) {
623 template <
class Iter>
633 template <
class Hasher>
638 template <
class Hasher,
typename T,
typename... Ts>
645 if (
sizeof...(ts) == 0) {
649 if (
sizeof(size_t) ==
sizeof(
uint32_t)) {
656 template <
typename Hash,
typename...
Value>
668 template <
typename T,
typename... Ts>
674 template <
typename...
Value>
681 template <
size_t index,
typename... Ts>
690 template <
typename... Ts>
703 #if FOLLY_SUPPLY_MISSING_INT128_TRAITS 708 struct hash<unsigned __int128>
714 template <
typename T1,
typename T2>
715 struct hash<std::
pair<T1, T2>> {
724 template <
typename... Ts>
725 struct hash<std::tuple<Ts...>> {
727 using FirstT = std::decay_t<std::tuple_element_t<0, std::tuple<Ts...,
bool>>>;
731 sizeof...(Ts) != 1 ||
754 template <
typename...
Args,
typename K>
uint64_t fnv64_buf(const void *buf, size_t n, uint64_t hash=FNV_64_HASH_START) noexcept
size_t operator()(std::tuple< Ts... > const &key) const
size_t operator()(I const &i) const noexcept
uint32_t jenkins_rev_unmix32(uint32_t key) noexcept
uint64_t commutative_hash_combine_range(Iter first, Iter last)
uint64_t hash_128_to_64(const uint64_t upper, const uint64_t lower) noexcept
uint64_t fnva64(const std::string &str, uint64_t hash=FNVA_64_HASH_START) noexcept
uint32_t hsieh_hash32_buf(const void *buf, size_t len) noexcept
uint64_t commutative_hash_combine_range_generic(uint64_t seed, Hash const &hasher, Iter first, Iter last)
size_t operator()(const std::tuple< Ts... > &key) const
size_t operator()(const std::pair< T1, T2 > &key) const
size_t operator()(F const &f) const noexcept
auto begin(TestAdlIterable &instance)
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
size_t operator()(std::tuple< Ts... > const &key) const
requires E e noexcept(noexcept(s.error(std::move(e))))
std::true_type folly_is_avalanching
uint32_t twang_32from64(uint64_t key) noexcept
const uint64_t FNV_64_HASH_START
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
uint64_t commutative_hash_combine_value_generic(uint64_t seed, Hash const &hasher, Value const &value)
bool_constant< true > true_type
size_t operator()(const T &t, const Ts &...ts) const
size_t operator()(T key) const noexcept
constexpr auto to_unsigned(T const &t) -> typename std::make_unsigned< T >::type
uint64_t hash_range(Iter begin, Iter end, uint64_t hash=0, Hash hasher=Hash())
std::true_type folly_is_avalanching
static uint64_t Hash64(const void *message, size_t length, uint64_t seed)
uint32_t fnv32_buf(const void *buf, size_t n, uint32_t hash=FNV_32_HASH_START) noexcept
def Iter(n, format, sep='')
uint32_t fnv32(const char *buf, uint32_t hash=FNV_32_HASH_START) noexcept
std::integral_constant< bool, B > bool_constant
bool Value(const T &value, M matcher)
size_t hash_combine(const T &t, const Ts &...ts) noexcept(noexcept(hash_combine_generic(StdHasher{}, t, ts...)))
auto end(TestAdlIterable &instance)
std::true_type folly_is_avalanching
uint64_t fnv64(const char *buf, uint64_t hash=FNV_64_HASH_START) noexcept
const uint32_t FNV_32_HASH_START
type_t< void, Ts... > void_t
size_t operator()(const std::pair< T1, T2 > &x) const
folly::bool_constant<(sizeof...(Ts)!=1||folly::IsAvalanchingHasher< std::hash< FirstT >, FirstT >::value)> folly_is_avalanching
uint64_t fnva64_buf(const void *buf, size_t n, uint64_t hash=FNVA_64_HASH_START) noexcept
const uint64_t FNVA_64_HASH_START
std::true_type folly_is_avalanching
std::true_type folly_is_avalanching
size_t operator()(bool key) const noexcept
uint64_t twang_mix64(uint64_t key) noexcept
size_t hash_combine_generic(const Hasher &) noexcept
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
uint64_t commutative_hash_combine_generic(uint64_t seed, Hash const &hasher, Value const &...value)
size_t operator()(const T &v) const noexcept(noexcept(hasher< T >()(v)))
const internal::AnythingMatcher _
size_t operator()(const T &t) const noexcept(noexcept(std::hash< T >()(t)))
size_t operator()(std::tuple< Ts... > const &key) const
size_t operator()(const std::string &key) const
std::decay_t< std::tuple_element_t< 0, std::tuple< Ts..., bool >>> FirstT
uint32_t hsieh_hash32(const char *s) noexcept
decltype(auto) constexpr apply(F &&func, Tuple &&tuple)
uint32_t hsieh_hash32_str(const std::string &str) noexcept
uint64_t commutative_hash_combine(Value const &...value)
uint64_t twang_unmix64(uint64_t key) noexcept
constexpr detail::First first
bool_constant<(sizeof(I) >=8||sizeof(size_t)==4)> folly_is_avalanching