31 lines
898 B
C
31 lines
898 B
C
|
#ifndef HT_INCLUDED
|
||
|
#define HT_INCLUDED
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <stddef.h>
|
||
|
|
||
|
#define FNV_PRIME 0x100000001b3
|
||
|
#define FNV_OFFSET 0xcbf29ce48422325UL
|
||
|
|
||
|
typedef enum {
|
||
|
SOFTFAIL = 0x1,
|
||
|
} TableFlags;
|
||
|
|
||
|
typedef uint64_t (hash_func) (const char *, size_t);
|
||
|
typedef void (cleanup_func) (void *ptr);
|
||
|
typedef struct Entry Entry;
|
||
|
typedef struct Hash_Table Hash_Table;
|
||
|
|
||
|
Hash_Table* hash_table_new(uint32_t size, hash_func *hf, cleanup_func *cf, int flags);
|
||
|
void hash_table_free(Hash_Table *ht);
|
||
|
void hash_table_print(Hash_Table *ht, int printNull);
|
||
|
uint64_t hash_table_create(Hash_Table *ht, const char *key, void *obj, int flags);
|
||
|
void* hash_table_read(Hash_Table *ht, const char *key);
|
||
|
void* hash_table_delete(Hash_Table *ht, const char *key);
|
||
|
|
||
|
uint64_t hash_fnv0(const char *buf, size_t len);
|
||
|
uint64_t hash_fnv1(const char *buf, size_t len);
|
||
|
uint64_t hash_fnv1a(const char *buf, size_t len);
|
||
|
|
||
|
#endif
|