#ifndef JOVE_LIB_HASHTABLE_H #define JOVE_LIB_HASHTABLE_H 1 #include #include #include "linkedlist.h" struct HashTableValue { const void *key; char value[]; }; struct HashTable { struct SLinkedList *buckets; size_t bucket_count; size_t bucket_capacity; size_t obj_size; int key_size; size_t (*hash_function)(const void*, size_t); }; void _hashtable_new(struct HashTable *table, size_t obj_size, size_t key_size); #define hashtable_new(table, type, keytype) _hashtable_new(table, sizeof(type), sizeof(keytype)) void _hashtable_news(struct HashTable *table, size_t obj_size); #define hashtable_news(table, type) _hashtable_news(table, sizeof(type)) void hashtable_insert(struct HashTable *table, const void *key, void *data); void *_hashtable_get(struct HashTable *table, const void *key); #define hashtable_get(table, key, type) (type*)_hashtable_get(table, key) #endif