-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_file.c
56 lines (40 loc) · 1.23 KB
/
test_file.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
// In this example file, we will define an elem as int.
// Change this line to what type you want elem to be. You can also put this
// line in the unrolled-list.h file.
typedef int elem;
#include "unrolled-list.c"
// Required client function for comparision and equality checks for elements.
bool unrolled_equality(elem elem1, elem elem2)
{
if (elem1 == elem2)
return true;
else
return false;
}
// Optional client function for printing elements of the list.
void printFunction(elem e)
{
printf("%d\n", e);
}
int main()
{
// Make new list. Each node has 3 elements size limit. Also pass in the
// Equality function to compare the elements of type elem.
ull* new = new_unrolled(3, &unrolled_equality);
insert_unrolled(1, new);
insert_unrolled(2, new);
// Print function.
// Pass in a list and a print function that prints elements of type elem.
printList(new, &printFunction);
delete_unrolled(2,new);
delete_unrolled(1,new);
insert_unrolled(3, new);
insert_unrolled(4, new);
printList(new, &printFunction);
delete_unrolled(3,new);
delete_unrolled(4,new);
printList(new, &printFunction);
// Free the list
free_unrolled(new);
return 0;
}