-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.h
More file actions
63 lines (49 loc) · 1.04 KB
/
Queue.h
File metadata and controls
63 lines (49 loc) · 1.04 KB
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
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
// Interface to the Queue ADT
// !!! DO NOT MODIFY THIS FILE !!!
#ifndef QUEUE_H
#define QUEUE_H
#include <stdbool.h>
#include <stdio.h>
typedef int Item;
typedef struct queue *Queue;
/**
* Creates a new empty queue
* Complexity: O(1)
*/
Queue QueueNew(void);
/**
* Frees all memory allocated to the given queue
* Complexity: O(n)
*/
void QueueFree(Queue q);
/**
* Adds an item to the end of the queue
* Complexity: O(1)
*/
void QueueEnqueue(Queue q, Item it);
/**
* Removes an item from the front of the queue and returns it
* Assumes that the queue is not empty
* Complexity: O(1)
*/
Item QueueDequeue(Queue q);
/**
* Gets the item at the front of the queue without removing it
* Assumes that the queue is not empty
* Complexity: O(1)
*/
Item QueueFront(Queue q);
/**
* Gets the size of the given queue
* Complexity: O(1)
*/
int QueueSize(Queue q);
/**
* Returns true if the queue is empty, and false otherwise
* Complexity: O(1)
*/
bool QueueIsEmpty(Queue q);
#endif