#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <derive-c/algorithm/hash/murmurhash.h>
#include <derive-c/core/prelude.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) { \
(void)key; \
return 0; \
}
The worst possible hash, for testing purposes.
Interesting literature:
Definition at line 13 of file hashers.h.
13#define ALWAYS_COLLIDE(type) \
14 static size_t hash_always_collide_##type(type const* key) { \
15 (void)key; \
16 return 0; \
17 }
◆ 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 21 of file hashers.h.
21#define ID(type) \
22 static size_t hash_id_##type(type const* key) { \
23 STATIC_ASSERT(sizeof(type) <= sizeof(size_t), \
24 "ID hashing only supports up to size_t integers"); \
25 return (size_t)(*key); \
26 }
◆ 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 40 of file hashers.h.
40#define INT_HASHERS(_apply) \
41 _apply(int8_t ) \
42 _apply(int16_t ) \
43 _apply(int32_t ) \
44 _apply(int64_t ) \
45 _apply(uint8_t ) \
46 _apply(uint16_t) \
47 _apply(uint32_t) \
48 _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"); \
}
INLINE uint64_t derive_c_fmix64(uint64_t k)
Using MurmurHash3's finalizer for integer hashing.
Definition at line 32 of file hashers.h.
32#define MURMURHASH_3_FMIx64(type) \
33 static size_t hash_murmurhash3_##type(type const* key) { \
34 STATIC_ASSERT(sizeof(type) <= sizeof(uint64_t), \
35 "MurmurHash3 only supports up to 64-bit integers"); \
36 return (size_t)derive_c_fmix64((uint64_t)(*key)); \
37 }
◆ 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, int32_t len, uint32_t seed)
Definition at line 78 of file hashers.h.
78#define MURMURHASH_STRING_FIXED_SIZE(size) \
79 static size_t hash_murmurhash_string_##size(const char str[size]) { \
80 return derive_c_murmurhash(str, size, MURMURHASH_DEFAULT_SEED); \
81 }
◆ 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 67 of file hashers.h.
67#define STRING_SIZES(_apply) \
68 _apply(1) \
69 _apply(2) \
70 _apply(3) \
71 _apply(4) \
72 _apply(5) \
73 _apply(6) \
74 _apply(7) \
75 _apply(8)
◆ hash_combine()
| size_t hash_combine |
( |
size_t | seed, |
|
|
size_t | h ) |
|
inlinestatic |
◆ hash_murmurhash_string()
| size_t hash_murmurhash_string |
( |
const char * | str | ) |
|