blob: 0c6a546a7d1a5ab64dfe7a7704becb4eb6f026f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef UTIL_HASH_H
#define UTIL_HASH_H
#include <stdint.h>
#include <stddef.h>
#include <string.h>
uint64_t murmur_hash_64a(void const * key, int len, unsigned int seed);
static inline uint64_t murmur_hash_str_64s(char const * str, unsigned int seed) {
return murmur_hash_64a(str, strlen(str), seed);
}
static inline uint64_t murmur64(uint64_t h) {
h ^= h >> 33;
h *= 0xff51afd7ed558ccdLLU;
h ^= h >> 33;
h *= 0xc4ceb9fe1a85ec53LLU;
h ^= h >> 33;
return h;
}
static inline size_t murmur64_range(uint64_t h, size_t n) {
return murmur64(h) % n;
}
#endif /* ifndef UTIL_HASH_H */
|