A simple introduction to HashTable in C
Add, Find, parse and del
struct hashTable {
int key;
int val;
UT_hash_handle hh;
};
struct hashTable* tmp;
HASH_FIND_INT(hashtable, &ikey, tmp);
test tmp == NULL
struct hashTable* tmp = malloc(sizeof(struct hashTable));
tmp->key = ikey, tmp->val = ival;
HASH_ADD_INT(hashtable, key, tmp);
struct HashTable *tmp, *iter;
HASH_ITER(hh, hashtable, iter, tmp) {
if (iter->count == 1) {
return iter->val;
}
HASH_DEL(hashtable, iter);
free(iter);
}