-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
70 lines (60 loc) · 1.61 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include "hashtable.h"
int main()
{
/**
* Old way of initializaing a hashtable
*
* Hashtable map;
* initialize_hashtable(&map);
*
* New way of initializing a hashtable
*
* Hashtable *map = initialize_hashtable();
*/
Hashtable *map = initialize_hashtable();
add_to_hashtable(&map, "sport");
add_to_hashtable(&map, "Sport");
add_to_hashtable(&map, "sport");
add_to_hashtable(&map, "train");
add_to_hashtable(&map, "Hello World!");
add_to_hashtable(&map, "Hello World!");
add_to_hashtable(&map, "Hello World!");
add_to_hashtable(&map, "Hello World!");
add_to_hashtable(&map, "Hello World!");
add_to_hashtable(&map, "Hello World");
add_to_hashtable(&map, "Apple");
char *key = "Hello World!";
int n = search_hashtable(map, key);
if (n != -1)
{
printf("Key \"%s\" has a value of %d\n", key, n);
}
char *key1 = "Hello Worl";
int n1 = search_hashtable(map, key1);
if (n1 != -1)
{
printf("Key \"%s\" has a value of %d\n", key1, n1);
}
int c = search_hashtable(map, "Sport");
if (c != -1)
{
printf("Key \"%s\" has a value of %d\n", "Sport", c);
}
key = "sport";
remove_from_hashtable(map, key);
print_hashtable(map);
add_to_hashtable(&map, "tree");
add_to_hashtable(&map, "Francais");
add_to_hashtable(&map, "Fourmi");
add_to_hashtable(&map, "Joe Dassin");
add_to_hashtable(&map, "Duran Duran");
add_to_hashtable(&map, "Queen");
add_to_hashtable(&map, "View to a Kill");
add_to_hashtable(&map, "Rio");
add_to_hashtable(&map, "Hungry");
print_hashtable(map);
free_hashtable(&map);
printf("\n");
return 0;
}