-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.h
67 lines (58 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
61
62
63
64
65
66
67
/*
* This file contains the definition of an interface for a queue data structure.
*/
#ifndef __QUEUE_H
#define __QUEUE_H
/*
* Structure used to represent a queue.
*/
struct queue;
/*
* Creates a new, empty queue and returns a pointer to it.
*/
struct queue* queue_create();
/*
* Free all of the memory associated with a queue.
*
* Params:
* queue - the queue to be destroyed. May not be NULL.
*/
void queue_free(struct queue* queue);
/*
* Returns 1 if the given queue is empty or 0 otherwise.
*
* Params:
* queue - the queue whose emptiness is to be checked. May not be NULL.
*/
int queue_isempty(struct queue* queue);
/*
* Enqueue a new value onto a queue.
*
* Params:
* queue - the queue onto which to enqueue a value. May not be NULL.
* value - the new value to be enqueueed onto the queue
*/
void queue_enqueue(struct queue* queue, int value);
/*
* Returns a queue's front value without removing that value from the queue.
*
* Params:
* queue - the queue from which to read the front value. May not be NULL or
* empty.
*
* Return:
* Returns the value stored at the front of the queue.
*/
int queue_front(struct queue* queue);
/*
* Removes the front element from a queue and returns its value.
*
* Params:
* queue - the queue from which to dequeue a value. May not be NULL or empty.
*
* Return:
* Returns the value stored at the front of the queue before that value is
* dequeued.
*/
int queue_dequeue(struct queue* queue);
#endif