00001 #ifndef HASHTABLE_H 00002 #define HASHTABLE_H 00003 00004 struct hashtable_entry { 00005 char *key; 00006 void *value; 00007 struct hashtable_entry *next; 00008 }; 00009 00010 struct hashtable { 00011 unsigned int (*hash) (const char*); 00012 unsigned int nbuckets; 00013 struct hashtable_entry **bucket; 00014 }; 00015 00016 void free_hashtable(struct hashtable *table); 00017 int hashtable_add(struct hashtable *table, char *key, void *value); 00018 unsigned int hashtable_default_hash(const char *key); 00019 void hashtable_iter(const struct hashtable *table, 00020 void (*func) (char *key, void *value)); 00021 void *hashtable_lookup(const struct hashtable *table, 00022 const char *key); 00023 struct hashtable *make_hashtable(unsigned int (*hash) (const char*), 00024 unsigned int nbuckets); 00025 00026 #endif /* ndef HASHTABLE_H */