-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.c
78 lines (58 loc) · 1.72 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
/**
*
* @file Queue.c
* @author Max Base ([email protected])
* @brief Queue data structure
* @version 0.1
* @date 2022-12-03
* @copyright Copyright (c) 2022
*
*/
#include "Queue.h"
int main(int argc, char** argv)
{
// Create a queue
Queue* queue = createQueue(5);
// Enqueue elements
enqueue(queue, 1);
// Print the front and rear
printf("Front: %d\n", getFront(queue));
printf("Rear: %d\n", getRear(queue));
enqueue(queue, 2);
// Print the front and rear
printf("Front: %d\n", getFront(queue));
printf("Rear: %d\n", getRear(queue));
enqueue(queue, 3);
// Print the front and rear
printf("Front: %d\n", getFront(queue));
printf("Rear: %d\n", getRear(queue));
enqueue(queue, 4);
// Print the front and rear
printf("Front: %d\n", getFront(queue));
printf("Rear: %d\n", getRear(queue));
enqueue(queue, 5);
// Print the front and rear
printf("Front: %d\n", getFront(queue));
printf("Rear: %d\n", getRear(queue));
// Check if the queue is full
if (isFull(queue)) {
printf("Queue is full!\n");
} else {
printf("Queue is not full!\n");
}
// Dequeue elements
printf("Dequeue: %d\n", dequeue(queue));
printf("Dequeue: %d\n", dequeue(queue));
printf("Dequeue: %d\n", dequeue(queue));
// Print the queue
printQueue(queue);
// Get the front element
printf("Front: %d\n", getFront(queue));
// Get the rear element
printf("Rear: %d\n", getRear(queue));
// Get the size of the queue
printf("Size: %d\n", getSize(queue));
// Destroy the queue
destroyQueue(queue);
return 0;
}