Hash Functions
include/math/hash.h View source View on GitHubFunctions
Section titled “Functions”hash_djb2
Section titled “hash_djb2”uint32_t hash_djb2(const void *key, size_t len) source Dan Bernstein’s algorithm
hash_sdbm
Section titled “hash_sdbm”uint32_t hash_sdbm(const void *key, size_t len) source SDBM database hash
hash_fnv1a
Section titled “hash_fnv1a”uint32_t hash_fnv1a(const void *key, size_t len) source 32-bit Fowler-Noll-Vo FNV-1a
hash_fnv1a_64_update
Section titled “hash_fnv1a_64_update”uint64_t hash_fnv1a_64_update(
uint64_t hash,
const void *key,
size_t len
) source hash_fnv1a_64
Section titled “hash_fnv1a_64”uint64_t hash_fnv1a_64(const void *key, size_t len) source hash_jenkins_qword
Section titled “hash_jenkins_qword”uint32_t hash_jenkins_qword(uint64_t key, uint32_t seed) source hash_jenkins_one_at_a_time
Section titled “hash_jenkins_one_at_a_time”uint32_t hash_jenkins_one_at_a_time(const void *key, size_t len) source hash_pointer
Section titled “hash_pointer”size_t hash_pointer(void *ptr) source hash_murmur3_32
Section titled “hash_murmur3_32”uint32_t hash_murmur3_32(const void *key, size_t len, uint32_t seed) source hash_elf
Section titled “hash_elf”uint32_t hash_elf(const void *key, size_t len) source Used in ELF file format, also called PJW hash
hash_bkdr
Section titled “hash_bkdr”uint32_t hash_bkdr(const void *key, size_t len) source Brian Kernighan and Dennis Ritchiie
Macros
Section titled “Macros”HASH_FNV1A_64_OFFSET_BASIS
Section titled “HASH_FNV1A_64_OFFSET_BASIS”#define HASH_FNV1A_64_OFFSET_BASIS UINT64_C(14695981039346656037) source HASH_FNV1A_64_PRIME
Section titled “HASH_FNV1A_64_PRIME”#define HASH_FNV1A_64_PRIME UINT64_C(1099511628211) source jhash_mix
Section titled “jhash_mix”#define jhash_mix(a, b, c) source Expansion
#define jhash_mix(a, b, c) \
{ \
a -= c; \
a ^= ((c) << 4) | ((c) >> 28); \
c += b; \
b -= a; \
b ^= ((a) << 6) | ((a) >> 26); \
a += c; \
c -= b; \
c ^= ((b) << 8) | ((b) >> 24); \
b += a; \
a -= c; \
a ^= ((c) << 16) | ((c) >> 16); \
c += b; \
b -= a; \
b ^= ((a) << 19) | ((a) >> 13); \
a += c; \
c -= b; \
c ^= ((b) << 4) | ((b) >> 28); \
b += a; \
} jhash_final
Section titled “jhash_final”#define jhash_final(a, b, c) source Expansion
#define jhash_final(a, b, c) \
{ \
c ^= b; \
c -= ((b) << 14) | ((b) >> 18); \
a ^= c; \
a -= ((c) << 11) | ((c) >> 21); \
b ^= a; \
b -= ((a) << 25) | ((a) >> 7); \
c ^= b; \
c -= ((b) << 16) | ((b) >> 16); \
a ^= c; \
a -= ((c) << 4) | ((c) >> 28); \
b ^= a; \
b -= ((a) << 14) | ((a) >> 18); \
c ^= b; \
c -= ((b) << 24) | ((b) >> 8); \
} HASH_MURMUR3_SEED_DEFAULT
Section titled “HASH_MURMUR3_SEED_DEFAULT”#define HASH_MURMUR3_SEED_DEFAULT 104729 source