1#ifndef MACHINATRIX_HASH_H
2#define MACHINATRIX_HASH_H
7#define MTRIX_HASHER_INIT ((struct mtrix_hasher){.h = 0x1505})
9typedef uint64_t mtrix_hash;
30static inline mtrix_hash mtrix_hash_str(
const char *s);
33static inline int mtrix_hash_cmp(
const void *lhs,
const void *rhs);
42 for(
char c; (c = *s++);)
43 h = mtrix_hasher_add(
h, c);
50 for(
const char *p = vp; n--;)
51 h = mtrix_hasher_add(
h, *p++);
55mtrix_hash mtrix_hash_str(
const char *s) {
56 return mtrix_hasher_add_str(MTRIX_HASHER_INIT, s).
h;
59int mtrix_hash_cmp(
const void *lhs_p,
const void *rhs_p) {
60 const mtrix_hash lhs = *(
const mtrix_hash*)lhs_p;
61 const mtrix_hash rhs = *(
const mtrix_hash*)rhs_p;
62 return lhs < rhs ? -1 : rhs < lhs ? 1 : 0;
Wraps a value with methods to compute hashes of several types.
Definition hash.h:12
mtrix_hash h
Final hashed value.
Definition hash.h:14