mirror of
https://github.com/azahar-emu/mcl
synced 2025-11-07 07:30:05 +01:00
mcl: hash: Add xmrx
This commit is contained in:
parent
322a221f07
commit
f1d902ce9b
30
include/mcl/hash/xmrx.hpp
Normal file
30
include/mcl/hash/xmrx.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This file is part of the mcl project.
|
||||||
|
// Copyright (c) 2022 merryhime
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// Reference: http://jonkagstrom.com/bit-mixer-construction/
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include "mcl/bit/rotate.hpp"
|
||||||
|
#include "mcl/stdint.hpp"
|
||||||
|
|
||||||
|
namespace mcl::hash {
|
||||||
|
|
||||||
|
constexpr size_t xmrx(size_t x)
|
||||||
|
{
|
||||||
|
x ^= x >> 32;
|
||||||
|
x *= 0xff51afd7ed558ccd;
|
||||||
|
x ^= bit::rotate_right(x, 47) ^ bit::rotate_right(x, 23);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct avalanche_xmrx {
|
||||||
|
size_t operator()(const T& value)
|
||||||
|
{
|
||||||
|
return xmrx(std::hash<T>{}(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcl::hash
|
||||||
Loading…
x
Reference in New Issue
Block a user