blob: adceca802b5ffc4e5c90dca409aee8a6f4eea60f (
plain)
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
|
// Jack Sangdahl
// CSCI3753 SP24
// PA6 Threaded Resolver
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct {
void *value;
} node;
typedef struct {
node *data;
int size;
int maxsize;
int front;
int back;
} queue;
/**
* @brief initialise the queue
* @param q
* @param size
* @return int
*/
int queue_init(queue *q, int size);
/**
* @brief return size of queue
* @param q
* @return int
*/
int queue_size(queue *q);
/**
* @brief return true if que size is
* greater than ARRAY_SIZE. false otherwise
* @param q
* @return bool
*/
bool queue_full(queue *q);
/**
* @brief add element to fifo queue. block when full
* @param q
* @param val
* @return int
*/
int queue_push(queue *q, void *val);
/**
* @brief return top element of queue in fifo order
* return null pointer if queue empty
* @param q
*/
void *queue_pop(queue *q);
/**
* @brief free queue's resources
* @param q
*/
void queue_free(queue *q);
|