make use of meow hash in the hash table

This commit is contained in:
Dennis Eichhorn 2022-11-20 16:55:45 +01:00
parent 382ef60919
commit b9a65135ff

View File

@ -15,6 +15,8 @@
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include "../Hash/MeowHash.h"
namespace Stdlib namespace Stdlib
{ {
namespace HashTable namespace HashTable
@ -42,13 +44,12 @@ namespace Stdlib
inline inline
unsigned long long hash_key(const char *key) unsigned long long hash_key(const char *key)
{ {
unsigned long long hash = 14695981039346656037UL; return (unsigned long long) MeowU64From(
for (const char *p = key; *p; ++p) { Hash::Meow::MeowHash(Hash::Meow::MeowDefaultSeed,
hash ^= (unsigned long long)(unsigned char)(*p); strlen(key),
hash *= 1099511628211UL; (void *) key),
} 0
);
return hash;
} }
ht *create_table(int max = 0, bool is_fixed = false) ht *create_table(int max = 0, bool is_fixed = false)