-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
29 lines (22 loc) · 744 Bytes
/
queue.h
File metadata and controls
29 lines (22 loc) · 744 Bytes
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
#pragma once
#include <stdlib.h>
/*
* A struct for a basic queue.
*
* The queue struct holds the list of elements as well as
* the current number of elements.
*/
typedef struct queue {
int size;
void **elements;
} queue_t;
/* Initializes the struct with an empty queue and size 0 */
void queue_init(queue_t *queue);
/* Adds the specified element to the queue and increments size by 1 */
void queue_add(queue_t *queue, void *element);
/* Removes first element in queue and decrements size by 1 */
void *queue_extract(queue_t *queue);
/* Returns current number of elements in the queue */
int queue_size(queue_t *queue);
/* Releases any memory and resources held internally by the queue */
void queue_release(queue_t *queue);