12#ifndef MFEM_HASH_UTIL_HPP
13#define MFEM_HASH_UTIL_HPP
38 uint64_t buf_[2] = {0, 0};
43 void init(uint64_t seed = 0);
46 void append(
const std::byte *vs, uint64_t bytes);
52 void add_block(uint64_t k1, uint64_t k2);
62 void finalize(uint64_t k1, uint64_t k2,
int num);
69 if constexpr (std::is_fundamental_v<T> || std::is_pointer_v<T>)
71 hasher.
append(
reinterpret_cast<const std::byte *
>(&value),
sizeof(T));
77 hasher.
append(
reinterpret_cast<std::byte *
>(&v),
sizeof(v));
95 for (
size_t i = 0; i < N; ++i)
106 static void AppendImpl(
Hasher &hasher,
const std::tuple<Ts...> &value)
109 hasher, std::get<N>(value));
110 if constexpr (N + 1 <
sizeof...(Ts))
112 AppendImpl<N + 1>(hasher, value);
119 if constexpr (
sizeof...(Ts))
121 AppendImpl<0>(hasher, value);
129 template <
class T,
class V>
134 hash.
init(0xfebd1fe69813c14full);
144 template <
class T,
size_t N>
149 hash.
init(0xfebd1fe69813c14full);
164 hash.
init(0xfebd1fe69813c14full);
Helper class for hashing std::array of a hashable type.
size_t operator()(const std::array< T, N > &v) const noexcept
static void Append(Hasher &hasher, const std::array< T, N > &value)
static void Append(Hasher &hasher, const std::pair< T, V > &value)
static void Append(Hasher &hasher, const std::tuple< Ts... > &value)
static void Append(Hasher &hasher, const T &value)
Streaming implementation of MurmurHash3 128 (x64).
void init(uint64_t seed=0)
Resets the Hasher back to an initial seed.
uint64_t data[2]
Storage for the final hash result after finalize() is called.
void append(const std::byte *vs, uint64_t bytes)
Append data vs of size bytes.
Helper class for hashing std::pair of hashable types.
size_t operator()(const std::pair< T, V > &v) const noexcept
Helper class for hashing std::tuple of hashable types.
size_t operator()(const T &v) const noexcept