diff options
| author | Franklin Wei <git@fwei.tk> | 2015-12-25 17:28:09 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-12-25 17:28:09 -0500 |
| commit | f7041112f179aa79b6e315e7d57afbf76d3cd8bb (patch) | |
| tree | c1c419845c0838ae15afe1da0cc54bf6447a760e /src/hash.h | |
| parent | 2a81620aa5b740d7f77aff8177a983b7492b8ea0 (diff) | |
| download | netcosm-f7041112f179aa79b6e315e7d57afbf76d3cd8bb.zip netcosm-f7041112f179aa79b6e315e7d57afbf76d3cd8bb.tar.gz netcosm-f7041112f179aa79b6e315e7d57afbf76d3cd8bb.tar.bz2 netcosm-f7041112f179aa79b6e315e7d57afbf76d3cd8bb.tar.xz | |
implement child lookup via hash table
Diffstat (limited to 'src/hash.h')
| -rw-r--r-- | src/hash.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -1,3 +1,4 @@ +#include <stdbool.h> #include <stddef.h> /* simple, generic chained hash map implementation */ @@ -17,6 +18,12 @@ void *hash_insert(void*, const void *key, const void *data); /* returns NULL if not found */ void *hash_lookup(void*, const void *key); +bool hash_remove(void *ptr, void *key); + +/* use like you would strtok_r */ +/* allocates a buffer that's freed once all elements are processed */ +void *hash_iterate(void *map, void **saved, void **keyptr); + struct hash_pair { void *key; unsigned char value[0]; @@ -25,6 +32,9 @@ struct hash_pair { /* insert n key->pair members of size pairsize */ void hash_insert_pairs(void*, const struct hash_pair*, size_t pairsize, size_t n); +/* gets the original pointer used to store the tuple */ +void *hash_getkeyptr(void*, const void *key); + #define SIMP_HASH(TYPE, NAME) \ unsigned NAME (const void *key) \ { \ |