-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQueue.cpp
More file actions
74 lines (63 loc) · 1.52 KB
/
Queue.cpp
File metadata and controls
74 lines (63 loc) · 1.52 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
63
64
65
66
67
68
69
70
71
72
73
74
#include "Queue.h"
template<class T>
Queue<T>::Queue(int max)
// Parameterized class constructor
// Post: maxQue, front, and rear have been initialized.
// The array to hold the queue elements has been dynamically
// allocated.
{
numItems = 0;
maxQue = max;
front = 0;
rear = maxQue - 1;
items = new T[maxQue];
}
template<class T>
Queue<T>::Queue() // Default class constructor
// Post: maxQue, front, and rear have been initialized.
// The array to hold the queue elements has been dynamically
// allocated.
{
numItems = 0;
maxQue = 500;
front = 0;
rear = maxQue - 1;
items = new T[maxQue];
}
template<class T>
Queue<T>::~Queue() // Class destructor
{
delete[] items;
}
template<class T>
void Queue<T>::MakeEmpty()
// Post: front and rear have been reset to the empty state.
{
front = 0;
rear = maxQue - 1;
}
template<class T>
bool Queue<T>::IsEmpty() const
// Returns true if the queue is empty; false otherwise.
{
return false;
}
template<class T>
bool Queue<T>::IsFull() const
// Returns true if the queue is full; false otherwise.
{
return false;
}
template<class T>
void Queue<T>::Enqueue(T newItem)
// Post: If (queue is not full) newItem is at the rear of the queue;
// otherwise a FullQueue exception is thrown.
{
}
template<class T>
T Queue<T>::Dequeue()
// Post: If (queue is not empty) the front of the queue has been
// removed and a copy returned in item;
// otherwise a EmptyQueue exception has been thrown.
{
}