diff options
author | Preston Pan <ret2pop@gmail.com> | 2024-12-28 16:47:43 -0800 |
---|---|---|
committer | Preston Pan <ret2pop@gmail.com> | 2024-12-28 16:47:43 -0800 |
commit | 1fd608288ee47c2c560817f12f14b21069fed2f6 (patch) | |
tree | e6460b92dba5bb0d089c8c2a4e794e3504098359 /src/include/hash_table.h | |
parent | 63f11aaec8d21844a07fd27003a992c102a3a297 (diff) |
makefile and directory structure change completely to build client and server
Diffstat (limited to 'src/include/hash_table.h')
-rw-r--r-- | src/include/hash_table.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/include/hash_table.h b/src/include/hash_table.h new file mode 100644 index 0000000..ea21e37 --- /dev/null +++ b/src/include/hash_table.h @@ -0,0 +1,43 @@ +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +#include <stdlib.h> +#define DEFAULT_HT_SIZE 500 + +typedef struct PAIR_STRUCT { + char *key; + void *v; +} pair_t; + +typedef struct NODE_STRUCT { + char *key; + void *v; + struct NODE_STRUCT *next; +} node_t; + +typedef struct { + node_t *head; + node_t *tail; +} sll_t; + +typedef struct { + sll_t **buckets; + size_t size; +} ht_t; + +node_t *init_node(char *key, void *v); + +void sll_push(sll_t *sll, char *key, void *v); + +void sll_delete(sll_t *sll, char *key); + +sll_t *sll_free(void *x, void (*freefunc)(void *)); + +void ht_insert(ht_t *ht, char *key, void *value); + +void ht_delete(ht_t *ht, char *key); + +void *ht_get(ht_t *ht, char *key); + +ht_t *init_ht(size_t size); +#endif |