Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Hash.hpp
1#pragma once
2
3#include "IntTypes.hpp"
4
5namespace Grindstone {
6 using HashValue = Uint64;
7
8 namespace Hash {
9 constexpr HashValue MurmurOAAT64(const char* key) {
10 HashValue h(525201411107845655ull);
11 for (; *key; ++key) {
12 h ^= *key;
13 h *= 0x5bd1e9955bd1e995;
14 h ^= h >> 47;
15 }
16 return h;
17 }
18
19 constexpr HashValue MurmurOAAT64(const char* key, size_t length) {
20 HashValue h(525201411107845655ull);
21 for (size_t i = 0; i < length; ++i) {
22 h ^= key[i];
23 h *= 0x5bd1e9955bd1e995;
24 h ^= h >> 47;
25 }
26 return h;
27 }
28
29 constexpr HashValue MurmurOAAT64(HashValue h, const char* key) {
30 for (; *key; ++key) {
31 h ^= *key;
32 h *= 0x5bd1e9955bd1e995;
33 h ^= h >> 47;
34 }
35 return h;
36 }
37
38 constexpr HashValue CombineMurmurOAAT64(HashValue h, const char* key, size_t length) {
39 for (size_t i = 0; i < length; ++i) {
40 h ^= key[i];
41 h *= 0x5bd1e9955bd1e995;
42 h ^= h >> 47;
43 }
44 return h;
45 }
46 };
47
48}