aboutsummaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
Diffstat (limited to 'example.c')
-rw-r--r--example.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/example.c b/example.c
index 4081c21..3b1bbb6 100644
--- a/example.c
+++ b/example.c
@@ -1,3 +1,5 @@
+#include "HashTable.h"
+#include "Types.h"
#include "Vector.h"
#include "String.h"
#include "BumpAlloc.h"
@@ -6,7 +8,7 @@
int
main() {
MemoryManager g = M_bump(KiB(2)),
- t = M_bump(KiB(3));
+ t = M_bump(KiB(4));
String *hexes = V_new(&g, sizeof(String), 8);
@@ -26,7 +28,22 @@ main() {
printf("%s", all);
+ MemoryManager T = M_std();
+
+ HashTable tet = H_new(&T, 16);
+ PRINT_NOTOK(H_insertstr(tet, "Hello", "World"));
+ PRINT_NOTOK(H_insertf(tet, "a", 1.414));
+ PRINT_NOTOK(H_inserti(tet, "+", 4829));
+
+ printf("Table: %s [%p] %f %d\n",
+ H_getstr(tet, "Hello"), H_getstr(tet, "Hello"),
+ H_getf(tet, "a") == NULL ? 0.0 : *H_getf(tet, "a"),
+ H_geti(tet, "+") == NULL ? 0 : *H_geti(tet, "+"));
+ PRINT_NOTOK(H_freevals(&tet));
+ PRINT_NOTOK(H_free(&tet));
+
PRINT_NOTOK(g.destroy(&g));
PRINT_NOTOK(t.destroy(&t));
+ PRINT_NOTOK(T.destroy(&T));
return 0;
}