-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
49 lines (31 loc) · 862 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "includes/hashtable.h"
int main () {
hashtable *ht = ht_create(50);
if (!ht) {
fprintf(stderr, "Error creating hash table...");
exit(EXIT_FAILURE);
}
ht_value v, w;
v.v = 123;
w.v = 789;
int ret = ht_insert(ht, "test", &v);
if (ret < 0) {
fprintf(stderr, "error inserting key...: %d\n", ret);
exit(EXIT_FAILURE);
}
fprintf(stdout, "Inserted test key, value %d.\n", v.v);
if (ht_keyexists(ht, "test") == HT_KEYEXISTS) {
fprintf(stdout, "Key test does exist.\n");
fprintf(stdout, "Value for test key is %d.\n", ht_getvalue(ht, "test")->v);
} else {
fprintf(stdout, "Key test does not exist.\n");
}
ht_insert(ht, "testagain", &v);
// ht_print(stdout, ht);
ht_deletenode(ht, "test");
ht_fill(ht, "ABC", &v, "XYZ", &w);
ht_print(stdout, ht);
ht_deletenode(ht, "ABC");
ht_print(stdout, ht);
ht_clear(ht);
}