A simple introduction to HashTable in C

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);
}

上一篇:Introduction to Fabric.js. Part 2(介绍Fabric.js第二部分)


下一篇:1.spring-介绍