-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.h
60 lines (53 loc) · 1.48 KB
/
queue.h
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
/**
* @File queue.h
*
* The header file that you need to implement for assignment 3.
*
* @author Andrew Quinn
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
/** @struct queue_t
*
* @brief This typedef renames the struct queue. Your `c` file
* should define the variables that you need for your queue.
*/
typedef struct queue queue_t;
/** @brief Dynamically allocates and initializes a new queue with a
* maximum size, size
*
* @param size the maximum size of the queue
*
* @return a pointer to a new queue_t
*/
queue_t *queue_new(int size);
/** @brief Delete your queue and free all of its memory.
*
* @param q the queue to be deleted. Note, you should assign the
* passed in pointer to NULL when returning (i.e., you should set
* *q = NULL after deallocation).
*
*/
void queue_delete(queue_t **q);
/** @brief push an element onto a queue
*
* @param q the queue to push an element into.
*
* @param elem th element to add to the queue
*
* @return A bool indicating success or failure. Note, the function
* should succeed unless the q parameter is NULL.
*/
bool queue_push(queue_t *q, void *elem);
/** @brief pop an element from a queue.
*
* @param q the queue to pop an element from.
*
* @param elem a place to assign the poped element.
*
* @return A bool indicating success or failure. Note, the function
* should succeed unless the q parameter is NULL.
*/
bool queue_pop(queue_t *q, void **elem);