From f7041112f179aa79b6e315e7d57afbf76d3cd8bb Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Fri, 25 Dec 2015 17:28:09 -0500 Subject: implement child lookup via hash table --- src/test.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/test.c') diff --git a/src/test.c b/src/test.c index 23a7530..95129e5 100644 --- a/src/test.c +++ b/src/test.c @@ -1,10 +1,19 @@ #include "hash.h" #include +#include int main() { - struct hash_map *map = hash_init(10, hash_djb, strcmp); - hash_insert(map, "a", 42); - hash_insert(map, "b", 32); - printf("weird. %d\n", hash_lookup(map, "a")); + void *map = hash_init(10000, hash_djb, compare_strings); + hash_insert(map, "a",1); + hash_insert(map, "b",2); + void *ptr = map; + void *data = NULL; + void *save; + do { + char *key; + data = hash_iterate(ptr, &save, &key); + ptr = NULL; + printf("%d %s\n", data, key); + } while(data); } -- cgit v1.1