2022-06-12 16:33:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Orange/Core/Types.h>
|
|
|
|
|
|
|
|
namespace orange
|
|
|
|
{
|
2022-08-25 07:27:11 +01:00
|
|
|
constexpr uint32_t hash_string(const char* s, size_t count)
|
2022-06-12 16:33:55 +01:00
|
|
|
{
|
2022-08-25 07:27:11 +01:00
|
|
|
return ((count ? hash_string(s, count - 1) : 2166136261u) ^ s[count]) * 16777619u;
|
2022-06-12 16:33:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
constexpr uint32_t operator"" _hash(const char* s, size_t count)
|
|
|
|
{
|
2022-08-25 07:27:11 +01:00
|
|
|
return hash_string(s, count);
|
2022-06-12 16:33:55 +01:00
|
|
|
}
|
2022-08-13 21:41:19 +01:00
|
|
|
|
2022-08-25 07:27:11 +01:00
|
|
|
inline size_t& hash_combine(size_t& seed) { (void)seed; return seed; }
|
2022-08-13 21:41:19 +01:00
|
|
|
|
|
|
|
template <typename T, typename... Rest>
|
2022-08-25 07:27:11 +01:00
|
|
|
inline size_t& hash_combine(size_t& seed, const T& v, Rest... rest)
|
2022-08-13 21:41:19 +01:00
|
|
|
{
|
|
|
|
std::hash<T> hasher;
|
|
|
|
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
2022-08-25 07:27:11 +01:00
|
|
|
hash_combine(seed, rest...);
|
2022-08-13 21:41:19 +01:00
|
|
|
return seed;
|
|
|
|
}
|
2022-06-12 16:33:55 +01:00
|
|
|
}
|