#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <derive-c/structures/hashmap/murmurhash.h>
Go to the source code of this file.
◆ ALWAYS_COLLIDE
#define ALWAYS_COLLIDE |
( |
| type | ) |
|
Value: static size_t hash_always_collide_##type(type const* key) { return 0; }
The worst possible hash, for testing purposes.
Interesting literature:
Definition at line 12 of file hashers.h.
12#define ALWAYS_COLLIDE(type) \
13 static size_t hash_always_collide_##type(type const* key) { return 0; }
◆ ID
Value: static size_t hash_id_##type(type const* key) { \
_Static_assert(sizeof(type) <= sizeof(size_t), \
"ID hashing only supports up to size_t integers"); \
return (size_t)(*key); \
}
No hashing, just returns the integer value. For most circumstances with a key as a single integer, this is a good option.
Definition at line 17 of file hashers.h.
17#define ID(type) \
18 static size_t hash_id_##type(type const* key) { \
19 _Static_assert(sizeof(type) <= sizeof(size_t), \
20 "ID hashing only supports up to size_t integers"); \
21 return (size_t)(*key); \
22 }
◆ INT_HASHERS
#define INT_HASHERS |
( |
| _apply | ) |
|
Value: _apply(int8_t ) \
_apply(int16_t ) \
_apply(int32_t ) \
_apply(int64_t ) \
_apply(uint8_t ) \
_apply(uint16_t) \
_apply(uint32_t) \
_apply(uint64_t)
Definition at line 36 of file hashers.h.
36#define INT_HASHERS(_apply) \
37 _apply(int8_t ) \
38 _apply(int16_t ) \
39 _apply(int32_t ) \
40 _apply(int64_t ) \
41 _apply(uint8_t ) \
42 _apply(uint16_t) \
43 _apply(uint32_t) \
44 _apply(uint64_t)
◆ MURMURHASH_3_FMIx64
#define MURMURHASH_3_FMIx64 |
( |
| type | ) |
|
Value: static size_t hash_murmurhash3_##type(type const* key) { \
_Static_assert(sizeof(type) <= sizeof(uint64_t), \
"MurmurHash3 only supports up to 64-bit integers"); \
}
FORCE_INLINE uint64_t derive_c_fmix64(uint64_t k)
Using MurmurHash3's finalizer for integer hashing.
Definition at line 28 of file hashers.h.
28#define MURMURHASH_3_FMIx64(type) \
29 static size_t hash_murmurhash3_##type(type const* key) { \
30 _Static_assert(sizeof(type) <= sizeof(uint64_t), \
31 "MurmurHash3 only supports up to 64-bit integers"); \
32 return (size_t)derive_c_fmix64((uint64_t)(*key)); \
33 }
◆ MURMURHASH_DEFAULT_SEED
#define MURMURHASH_DEFAULT_SEED 0x9747b28c |
◆ MURMURHASH_STRING_FIXED_SIZE
#define MURMURHASH_STRING_FIXED_SIZE |
( |
| size | ) |
|
Value: static size_t hash_murmurhash_string_##
size(
const char str[
size]) { \
}
static INDEX_TYPE size(SELF const *self)
#define MURMURHASH_DEFAULT_SEED
size_t derive_c_murmurhash(const void *key, int len, uint32_t seed)
Definition at line 73 of file hashers.h.
73#define MURMURHASH_STRING_FIXED_SIZE(size) \
74 static size_t hash_murmurhash_string_##size(const char str[size]) { \
75 return derive_c_murmurhash(str, size, MURMURHASH_DEFAULT_SEED); \
76 }
◆ STRING_SIZES
#define STRING_SIZES |
( |
| _apply | ) |
|
Value: _apply(1) \
_apply(2) \
_apply(3) \
_apply(4) \
_apply(5) \
_apply(6) \
_apply(7) \
_apply(8)
Definition at line 63 of file hashers.h.
63#define STRING_SIZES(_apply) \
64 _apply(1) \
65 _apply(2) \
66 _apply(3) \
67 _apply(4) \
68 _apply(5) \
69 _apply(6) \
70 _apply(7) \
71 _apply(8)
◆ hash_combine()
static size_t hash_combine |
( |
size_t | seed, |
|
|
size_t | h ) |
|
inlinestatic |
- Examples
- structures/hashmap.c.
Definition at line 83 of file hashers.h.
83 {
84
85
86 return seed ^ (h + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2));
87}
◆ hash_murmurhash_string()
size_t hash_murmurhash_string |
( |
const char * | str | ) |
|