28 lines
704 B
C++
28 lines
704 B
C++
#pragma once
|
|
|
|
#include <Orange/Core/Types.h>
|
|
|
|
namespace orange
|
|
{
|
|
constexpr uint32_t HashString(const char* s, size_t count)
|
|
{
|
|
return ((count ? HashString(s, count - 1) : 2166136261u) ^ s[count]) * 16777619u;
|
|
}
|
|
|
|
constexpr uint32_t operator"" _hash(const char* s, size_t count)
|
|
{
|
|
return HashString(s, count);
|
|
}
|
|
|
|
inline size_t& hashCombine(size_t& seed) { (void)seed; return seed; }
|
|
|
|
template <typename T, typename... Rest>
|
|
inline size_t& hashCombine(size_t& seed, const T& v, Rest... rest)
|
|
{
|
|
std::hash<T> hasher;
|
|
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
|
hashCombine(seed, rest...);
|
|
return seed;
|
|
}
|
|
}
|