From fd14f6fbf8206589d2a0ad8f0793845cb8faf1d7 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 26 Dec 2024 21:18:05 -0800 Subject: stuff --- include/hash_table.h | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'include/hash_table.h') diff --git a/include/hash_table.h b/include/hash_table.h index 16d8fe9..357e38a 100644 --- a/include/hash_table.h +++ b/include/hash_table.h @@ -1,14 +1,43 @@ #ifndef HASH_TABLE_H #define HASH_TABLE_H +#include + +#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 -- cgit