-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queue.h
99 lines (83 loc) · 2.19 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* COMP2521 - Data Structures and Algorithms
* Assignment 2 - Simple Search Engines
*
* Group: TwoBrothers
*
* Partners: Kurt Banwell-Pachernegg (Z5022859)
* Sam Eager (Z3414861)
*/
#ifndef QUEUE_H
#define QUEUE_H
// A basic queue.
typedef struct Queue * Queue;
/*
* Creates a new empty Queue.
* Time complexity: O(1)
*/
Queue newQueue();
/*
* Adds a value to the end of the Queue
* Time complexity: O(1)
*/
int addQueue(Queue queue, void * value);
/*
* Removes the first value in the queue and returns the value.
* Time complexity: O(1)
*/
void * nextQueue(Queue queue);
/*
* Returns the first value in the queue.
* Time complexity: O(1)
*/
void * peakQueue(Queue queue);
/*
* Checks if the queue is empty, returns 1 if it isn't and 0 otherwise.
* Time complexity: O(1)
*/
int emptyQueue(Queue queue);
/*
* Returns the current size of the queue (how many values are stored in
* the queue).
*
* Time complexity: O(1)
*/
int sizeQueue(Queue queue);
// Provides a way to iterate over a Queue without destroying it.
typedef struct QueueIterator * QueueIterator;
/*
* Creates a new iterater for a given Queue. The iterator is initalised to
* start at the beginning of the Queue.
* Time complexity: O(1)
*/
QueueIterator newQueueIterator(Queue queue);
/*
* Checks if the itterator is at the end of the Queue
* (i.e. nextQueueIterator(QueueIterator iterator) would return NULL if called
* in the iterators current state).
*
* Time complexity: O(1)
*/
int hasNextQueueIterator(QueueIterator iterator);
/*
* Gets the next value from where the iterator is pointing in the Queue
* and moves the pointer forward one.
*
* Time complexity: O(1)
*/
void * nextQueueIterator(QueueIterator iterator);
/*
* Gets the next value from where the iterator is pointing WITHOUT
* moving the pointer forward (i.e. No matter how many times this is
* called successively, the result will be the same).
*
* Time complexity: O(1)
*/
void * peakQueueIterator(QueueIterator iterator);
/*
* Moves the iterator pointer back to the start of the queue.
*
* Time complexity: O(1)
*/
void resetQueueIterator(QueueIterator iterator);
#endif