#if !defined(HASHTABLE_H)
#define HASHTABLE_H

#include "linkedlist.h"

typedef struct hashtable {
    node **table;       // array of linked list heads
    int table_size;
} hashtable;

// Create a hash table with the given number of buckets
hashtable *ht_create(int table_size);

// Compute hash(key) -- maps a string to an index in 0..table_size-1
int ht_hash(const char *key, int table_size);

// Insert a (key, value) pair into the hash table
void ht_put(hashtable *ht, const char *key, const char *value);

// Look up a key. Return the value if found, NULL otherwise.
char *ht_get(hashtable *ht, const char *key);

// Free the hash table and all its chains
void ht_destroy(hashtable *ht);

#endif
