-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.c
83 lines (60 loc) · 1.59 KB
/
example.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
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "CircularLinkedList.h"
/**
* @brief Main entry point
*
* @param argc
* @param argv
* @return * int
*/
int main(int argc, char** argv)
{
// Create a new list
CircularLinkedList *list = createNewCircularLinkedList();
// Insert some nodes
insertAtBeginning(list, 1);
insertAtBeginning(list, 2);
insertAtBeginning(list, 3);
insertAtBeginning(list, 4);
insertAtBeginning(list, 5);
// Print the list
printList(list);
// Insert a node at the end
insertAtEnd(list, 6);
// Print the list
printList(list);
// Insert a node at the given position
insertAtPosition(list, 7, 3);
// Print the list
printList(list);
// Reverse the list
reverseList(list);
// Print the list
printList(list);
// Reverse the list recursively
// reverseListRecursive(list);
// Print the list
printList(list);
// Delete the first node
deleteFirstNode(list);
// Print the list
printList(list);
// Delete the last node
deleteLastNode(list);
// Print the list
printList(list);
// Delete the node at the given position
deleteNodeAtPosition(list, 3);
// Print the list
printList(list);
// Search for a node
printf("Search for 3: %s\n", search(list, 3) ? "true" : "false");
// Print the list in reverse order
printListReverse(list);
// Delete the list
deleteList(list);
// Print the list
printList(list);
// Free the list
freeList(list);
return 0;
}