28 lines
761 B
C
28 lines
761 B
C
#ifndef HASH_H_
|
|
#define HASH_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct HashEntry {
|
|
const char *key;
|
|
void *value;
|
|
size_t sz;
|
|
} HashEntry;
|
|
|
|
typedef struct {
|
|
HashEntry **buckets;
|
|
size_t capacity;
|
|
} HashTable;
|
|
|
|
void hashtable_init (HashTable *t, size_t capacity);
|
|
void hashtable_deinit (HashTable *t);
|
|
HashEntry * hashtable_new (const char *key, void *value, size_t sz);
|
|
void * hashtable_get (HashTable *t, const char *key);
|
|
void hashtable_set (HashTable *t, const char *key, void *value, size_t sz);
|
|
bool hashtable_delete (HashTable *t, const char *key);
|
|
bool hashtable_check (HashTable *t, const char *key);
|
|
|
|
#endif // HASH_H_
|