Added HashCombine function
Former-commit-id: 852deae33143138f2841e226690bfef94d3ba2b9
This commit is contained in:
@@ -30,6 +30,23 @@ struct NzImplTupleUnpack<0>
|
||||
}
|
||||
};
|
||||
|
||||
// Algorithme venant de CityHash par Google
|
||||
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
|
||||
template<typename T>
|
||||
void NzHashCombine(std::size_t& seed, const T& v)
|
||||
{
|
||||
const std::size_t kMul = 0x9ddfea08eb382d69ULL;
|
||||
|
||||
std::hash<T> hasher;
|
||||
std::size_t a = (hasher(v) ^ seed) * kMul;
|
||||
a ^= (a >> 47);
|
||||
|
||||
std::size_t b = (seed ^ a) * kMul;
|
||||
b ^= (b >> 47);
|
||||
|
||||
seed = b * kMul;
|
||||
}
|
||||
|
||||
template<typename F, typename... ArgsT>
|
||||
void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user