aboutsummaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-12-25 17:28:09 -0500
committerFranklin Wei <frankhwei536@gmail.com>2015-12-25 17:28:09 -0500
commitc949ff2ac3fca2bee3c3c6e97a63d151b7c31594 (patch)
treec1c419845c0838ae15afe1da0cc54bf6447a760e /src/test.c
parentc8e8d7de47a829f9dbc18b1072453c7a48e67ddb (diff)
downloadnetcosm-c949ff2ac3fca2bee3c3c6e97a63d151b7c31594.zip
netcosm-c949ff2ac3fca2bee3c3c6e97a63d151b7c31594.tar.gz
netcosm-c949ff2ac3fca2bee3c3c6e97a63d151b7c31594.tar.bz2
netcosm-c949ff2ac3fca2bee3c3c6e97a63d151b7c31594.tar.xz
implement child lookup via hash table
Diffstat (limited to 'src/test.c')
-rw-r--r--src/test.c17
1 files changed, 13 insertions, 4 deletions
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 <string.h>
+#include <stdio.h>
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);
}