Nebula
Loading...
Searching...
No Matches
hash.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
11
12
#include "
core/types.h
"
13
14
//------------------------------------------------------------------------------
15
namespace
Util
16
{
17
uint32_t
Hash
(
const
uint8_t* key,
SizeT
len, uint32_t seed = 4711)
18
{
19
20
const
static
auto
murmur_scramble = [](uint32_t k)
21
{
22
k *= 0xcc9e2d51;
23
k = (k << 15) | (k >> 17);
24
k *= 0x1b873593;
25
return
k;
26
};
27
28
uint32_t h = seed;
29
uint32_t k;
30
31
for
(
size_t
i = len >> 2; i; i--)
32
{
33
Memory::Copy
(key, &k, 4);
34
key +=
sizeof
(uint32_t);
35
h ^= murmur_scramble(k);
36
h = (h << 13) | (h >> 19);
37
h = h * 5 + 0xe6546b64;
38
}
39
k = 0;
40
for
(
size_t
i = len & 3; i; i--)
41
{
42
k <<= 8;
43
k |= *key++;
44
}
45
h ^= murmur_scramble(k);
46
h ^= (uint32_t)len;
47
h ^= h >> 16;
48
h *= 0x85ebca6b;
49
h ^= h >> 13;
50
h *= 0xc2b2ae35;
51
h ^= h >> 16;
52
return
h;
53
}
54
55
}
Memory::Copy
void Copy(const void *from, void *to, size_t numBytes)
Copy a chunk of memory (note the argument order is different from memcpy()!
Definition
osxmemory.cc:213
Util
A pinned array is an array which manages its own virtual memory.
Definition
String.cs:6
Util::Hash
uint32_t Hash(const uint8_t *key, SizeT len, uint32_t seed=4711)
Definition
hash.h:17
types.h
SizeT
int SizeT
Definition
types.h:42
code
foundation
util
hash.h
Generated on Sat Jan 17 2026 19:54:45 for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.