-/*
- * A basic implementation of a hash-set. Unlike a hashtable, a hash
- * set doesn't maintain key-value pairs. It simply maintains a key
- * that can be set, removed, and checked for.
- *
- * See EXPOSED interface comment below
- */
-#define GMQCC_HASHSET_PRIME0 0x0049
-#define GMQCC_HASHSET_PRIME1 0x1391
-
-static int util_hsput(hash_set_t *set, void *item) {
- size_t hash = (size_t)item; /* shouldn't drop the bits */
- size_t iter;
-
- /* a == 0 || a == 1 */
- if (hash >> 1)
- return -1;
-
- iter = set->mask & (GMQCC_HASHSET_PRIME0 * hash);
-
- /* while (set->items[iter] != 0 && set->items[iter] != 1) */
- while (!(set->items[iter] >> 1)) {
- if (set->items[iter] == hash)
- return 0;
-
- iter = set->mask & (iter + GMQCC_HASHSET_PRIME1);
- }
-
- set->total ++;
- set->items[iter] = hash;
-
- return 1;
-}
-
-static void util_hsupdate(hash_set_t *set) {
- size_t *old;
- size_t end;
- size_t itr;
-
- /* time to rehash? */
- if ((float)set->total >= (size_t)((double)set->capacity * 0.85)) {
- old = set->items;
- end = set->capacity;
-
- set->bits ++;
- set->capacity = (size_t)(1 << set->bits);
- set->mask = set->capacity - 1;
- set->items = mem_a(set->capacity * sizeof(size_t));
- set->total = 0;
+void util_htrmh(hash_table_t *ht, const char *key, size_t bin, void (*cb)(void*)) {
+ hash_node_t **pair = &ht->table[bin];
+ hash_node_t *tmp;