forked from fgrandoinf/centrality-measures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.h
71 lines (59 loc) · 1.73 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
68
69
70
71
#ifndef _QUEUE_H
#define _QUEUE_H
/*
* Type: queueElementT
* -------------------
* This is the type of objects held in the queue.
*/
typedef int queueElement;
/*
* Type: queue
* --------------
* The actual implementation of a queue is completely
* hidden. Client will work with queueADT which is a
* pointer to underlying queueCDT.
*/
typedef struct {
queueElement *contents;
int front;
int count;
int maxSize;
} queue;
/*
* Function: QueueCreate
* Usage: queue = QueueCreate();
* -------------------------
* A new empty queue is created and returned.
*/
void QueueInit(queue *queue, int maxSize);
/* Function: QueueDestroy
* Usage: QueueDestroy(queue);
* -----------------------
* This function frees all memory associated with
* the queue. "queue" may not be used again unless
* queue = QueueCreate() is called first.
*/
void QueueDestroy(queue *queue);
/*
* Functions: QueueEnter, QueueDelete
* Usage: QueueEnter(queue, element);
* element = QueueDelete(queue);
* --------------------------------------------
* These are the fundamental queue operations that enter
* elements in and delete elements from the queue. A call
* to QueueDelete() on an empty queue or to QueueEnter()
* on a full queue is an error. Make use of QueueIsFull()
* and QueueIsEmpty() (see below) to avoid these errors.
*/
void QueueEnter(queue *queue, queueElement element);
queueElement QueueDelete(queue *queue);
/*
* Functions: QueueIsEmpty, QueueIsFull
* Usage: if (QueueIsEmpty(queue)) ...
* -----------------------------------
* These return a true/false value based on whether
* the queue is empty or full, respectively.
*/
int QueueIsEmpty(queue *queue);
int QueueIsFull(queue *queue);
#endif /* not defined _QUEUE_H */