void hashmap_free(Hashmap*h) {
+ /* Free the hashmap, but nothing in it */
+
if (!h)
return;
}
void hashmap_free_free(Hashmap *h) {
+
+ /* Free the hashmap and all data objects in it, but not the
+ * keys */
+
if (!h)
return;
return NULL;
hash = h->hash_func(key) % NBUCKETS;
-
- if (!(e = hash_scan(h, hash, key)))
+ e = hash_scan(h, hash, key);
+ if (!e)
return NULL;
return e->value;
bool hashmap_contains(Hashmap *h, const void *key) {
unsigned hash;
- struct hashmap_entry *e;
if (!h)
return false;
hash = h->hash_func(key) % NBUCKETS;
- if (!(e = hash_scan(h, hash, key)))
+ if (!hash_scan(h, hash, key))
return false;
return true;
return sv;
}
+
+void *hashmap_next(Hashmap *h, const void *key) {
+ unsigned hash;
+ struct hashmap_entry *e;
+
+ assert(h);
+ assert(key);
+
+ if (!h)
+ return NULL;
+
+ hash = h->hash_func(key) % NBUCKETS;
+ e = hash_scan(h, hash, key);
+ if (!e)
+ return NULL;
+
+ e = e->iterate_next;
+ if (!e)
+ return NULL;
+
+ return e->value;
+}