roo_collections
API Documentation for roo_collections
Loading...
Searching...
No Matches
hash.cpp
Go to the documentation of this file.
1
#include "
roo_collections/hash.h
"
2
3
namespace
roo_collections
{
4
5
static
inline
uint32_t
murmur_32_scramble
(
uint32_t
k
) {
6
k
*= 0xcc9e2d51;
7
k
= (
k
<< 15) | (
k
>> 17);
8
k
*= 0x1b873593;
9
return
k
;
10
}
11
12
uint32_t
murmur3_32
(
const
void
*
key
,
size_t
len
,
uint32_t
seed
) {
13
const
unsigned
char
*
buf
= (
const
unsigned
char
*)
key
;
14
uint32_t
h
=
seed
;
15
uint32_t
k
;
16
for
(
size_t
i
=
len
>> 2;
i
;
i
--) {
17
k
= (
buf
[0] << 24) | (
buf
[1] << 16) | (
buf
[2] << 8) | (
buf
[3]);
18
buf
+= 4;
19
h
^=
murmur_32_scramble
(
k
);
20
h
= (
h
<< 13) | (
h
>> 19);
21
h
=
h
* 5 + 0xe6546b64;
22
}
23
k
= 0;
24
for
(
size_t
i
=
len
& 3;
i
;
i
--) {
25
k
<<= 8;
26
k
|=
buf
[
i
- 1];
27
}
28
h
^=
murmur_32_scramble
(
k
);
29
h
^=
len
;
30
h
^=
h
>> 16;
31
h
*= 0x85ebca6b;
32
h
^=
h
>> 13;
33
h
*= 0xc2b2ae35;
34
h
^=
h
>> 16;
35
return
h
;
36
}
37
38
}
// namespace roo_collections
hash.h
Hashing utilities used by roo_collections containers.
roo_collections
Definition
roo_collections.h:10
roo_collections::murmur3_32
uint32_t murmur3_32(const void *key, size_t len, uint32_t seed)
Computes 32-bit MurmurHash3 of a binary buffer.
Definition
hash.cpp:12
roo_collections::murmur_32_scramble
static uint32_t murmur_32_scramble(uint32_t k)
Definition
hash.cpp:5
roo_collections::DefaultHashFn
Definition
flat_small_hashtable.h:71
temp_repos
roo_collections
src
roo_collections
hash.cpp
Generated by
1.9.8