14template <
typename T>
struct vec2;
27 FL_DISABLE_WARNING_IMPLICIT_FALLTHROUGH;
30 const int nblocks = int(len / 4);
33 const u32 c1 = 0xcc9e2d51;
34 const u32 c2 = 0x1b873593;
37 const u32 *blocks =
reinterpret_cast<const u32 *
>(data);
38 for (
int i = 0; i < nblocks; ++i) {
41 k1 = (k1 << 15) | (k1 >> 17);
45 h1 = (h1 << 13) | (h1 >> 19);
46 h1 = h1 * 5 + 0xe6546b64;
50 const fl::u8 *tail = data + (nblocks * 4);
54 k1 ^= u32(tail[2]) << 16;
56 k1 ^= u32(tail[1]) << 8;
60 k1 = (k1 << 15) | (k1 >> 17);
83 x = (
x ^ 61u) ^ (
x >> 16);
93 u32 seed = 0) noexcept {
100 u32 x1 =
static_cast<u32
>(
x & 0x00000000FFFFFFFF);
101 u32 x2 =
static_cast<u32
>(
x >> 32);
109template <
typename T>
struct Hash {
111 "fl::Hash<T> only supports POD types (integrals, floats, "
112 "etc.), you need to define your own hash.");
120 "fl::FastHash<T> only supports POD types (integrals, floats, "
121 "etc.), you need to define your own hash.");
129 if (
sizeof(T) ==
sizeof(
fl::u8)) {
130 u32
x =
static_cast<u32
>(key.x) +
131 (
static_cast<u32
>(key.y) << 8);
134 if (
sizeof(T) ==
sizeof(u16)) {
135 u32
x =
static_cast<u32
>(key.x) +
136 (
static_cast<u32
>(key.y) << 16);
139 if (
sizeof(T) ==
sizeof(u32)) {
146template <
typename T>
struct Hash<T *> {
148 if (
sizeof(T *) ==
sizeof(u32)) {
149 u32 key_u =
reinterpret_cast<fl::uptr
>(key);
160#pragma GCC diagnostic push
161#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
163 T packed[2] = {key.x, key.y};
164 const void *p = &packed[0];
167#pragma GCC diagnostic pop
175 return hasher(key.get());
181 fl::uptr val = key.ptr_value();
193template<>
struct Hash<double> {
201 u32 ukey =
static_cast<u32
>(key);
232 u8 v =
static_cast<u8>(key);
239 u16 ukey =
static_cast<u16
>(key);
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
static u32 hash_pair(u32 a, u32 b, u32 seed=0) noexcept
To bit_cast(const From &from) noexcept
static u32 fast_hash64(u64 x) noexcept
static u32 MurmurHash3_x86_32(const void *key, fl::size len, u32 seed=0)
static u32 fast_hash32(u32 x) noexcept
u32 operator()(const vec2< T > &key) const noexcept
u32 operator()(const T &key) const noexcept
u32 operator()(T *key) const noexcept
u32 operator()(const bool key) const noexcept
u32 operator()(const double &key) const noexcept
u32 operator()(const fl::WeakPtr< T > &key) const noexcept
u32 operator()(const T &key) const noexcept
u32 operator()(const fl::string &key) const noexcept
u32 operator()(const fl::u8 &key) const noexcept
u32 operator()(const float key) const noexcept
u32 operator()(const i16 &key) const noexcept
u32 operator()(const i32 key) const noexcept
u32 operator()(const i8 &key) const noexcept
u32 operator()(const u16 &key) const noexcept
u32 operator()(const u32 &key) const noexcept
u32 operator()(const vec2< T > &key) const noexcept
u32 operator()(const T &key) const noexcept
static constexpr bool value