#ifndef HASH_TABLE_H #define HASH_TABLE_H #include "list.h" #include #define DEFAULT_HT_SIZE 500 typedef struct PAIR_STRUCT { char *key; void *v; } pair_t; typedef struct { list_t **buckets; size_t size; } ht_t; pair_t *init_pair(char *key, void *value); void *bucket_get(list_t *b, char *key); void *bucket_pop(list_t *b, char *key); void bucket_free(void *x, void (*freefunc)(void *)); ht_t *init_ht(size_t size); void ht_insert(ht_t *ht, char *key, void *value); void *ht_pop(ht_t *ht, char *key); void *ht_get(ht_t *ht, char *key); void ht_free(void *x, void (*freefunc)(void *)); /* djb2 hash function */ unsigned long hash(char *key); #endif