
#ifndef HASH_TABLE_H
#define HASH_TABLE_H

#define DEFAULT_NR_BUCKETS	((1 << 7) - 1)

typedef struct _HashTable HashTable;
typedef struct _HashNode HashNode;
typedef enum _HashTableError HashTableError;

struct _HashTable {
	HashNode* buckets;
	int nr_buckets;
	HashTableError last_error;
};

struct _HashNode {
	char* key;
	void* data;
	HashNode* next;
};

enum _HashTableError {
	HTE_None = 0,
	HTE_NotFound,
	HTE_AllocationFailed,
	HTE_KeyIsNull,
	HTE_InvalidHash,	/* Shouldn't this be an internal error? */
	HTE_KeyExists
};



HashTable* hash_table_new (void);

HashTable* hash_table_new_with_options (int nr_buckets);

HashTableError hash_table_insert (HashTable* ht, char* key, void* data);

HashNode* hash_table_find (HashTable* ht, char* key);

int hash_table_dump_stats (HashTable* ht, FILE* f);

HashTableError hash_table_get_last_error (HashTable*);



#endif /* HASH_TABLE_H */
