-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
115 lines (100 loc) · 2.37 KB
/
queue.h
File metadata and controls
115 lines (100 loc) · 2.37 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* ================================================
*
* Copyright 2017-2025 Manoel Vilela
*
* Author: Manoel Vilela
* Contact: manoel_vilela@engineer.com
* Organization: UFC
*
* ===============================================
*/
#ifndef QUEUE_H
#define QUEUE_H
/**
* @brief A queue data structure.
*/
typedef struct queue Queue;
#define EMPTY_QUEUE (Queue*) 0
#ifndef QUEUE_STATIC_MAX
#define QUEUE_STATIC_MAX 1000000
#endif
/**
* @brief Creates an empty queue.
*
* @return A pointer to the new queue.
* @ingroup DataStructureMethods
*/
Queue* queue_create(void);
/**
* @brief Checks if a queue is empty.
*
* @param q The queue to check.
* @return 1 if the queue is empty, 0 otherwise.
* @ingroup DataStructureMethods
*/
int queue_empty(Queue *q);
/**
* @brief Inserts an element at the back of a queue.
*
* @param q The queue to insert into.
* @param data The data to insert.
* @ingroup DataStructureMethods
*/
void queue_insert(Queue *q, int data);
/**
* @brief Removes and returns the element at the front of a queue.
*
* @param q The queue to remove from.
* @return The element at the front of the queue.
* @ingroup DataStructureMethods
*/
int queue_remove(Queue *q);
/**
* @brief Prints the elements of a queue to the console.
*
* @param q The queue to print.
* @ingroup DataStructureMethods
*/
void queue_print(Queue *q);
/**
* @brief Prints the elements of a queue to the console, followed by a newline
* character.
*
* @param q The queue to print.
* @ingroup DataStructureMethods
*/
void queue_println(Queue *q);
/**
* @brief Frees the memory allocated for a queue.
*
* @param q The queue to free.
* @ingroup DataStructureMethods
*/
void queue_free(Queue *q);
/**
* @brief Reverses the elements of a queue.
*
* @param q The queue to reverse.
* @ingroup DataStructureMethods
*/
void queue_reverse(Queue *q);
/**
* @brief Counts the number of elements in a queue that are greater than a given
* value.
*
* @param q The queue to search.
* @param n The value to compare against.
* @return The number of elements greater than n.
* @ingroup DataStructureMethods
*/
int queue_greater_than(Queue *q, int n);
/**
* @brief Counts the number of even elements in a queue.
*
* @param q The queue to search.
* @return The number of even elements.
* @ingroup DataStructureMethods
*/
int queue_evens(Queue *q);
#endif