-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.cpp
More file actions
79 lines (71 loc) · 777 Bytes
/
Copy pathQueue.cpp
File metadata and controls
79 lines (71 loc) · 777 Bytes
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
#include"queue.h"
template<class T>
queue<T>::queue()
{
front = 0;
rear = -1;
}
template<class T>
bool queue<T>::isEmpty()
{
if (rear == -1)
{
return true;
}
return false;
}
template<class T>
bool queue<T>::isFull()
{
if (rear == max)
{
return true;
}
else
{
return false;
}
}
template<class T>
void queue<T>::enqueue(T v)
{
if (!isFull())
{
rear++;
array[rear] = v;
}
}
template<class T>
void queue<T>::dequeue()
{
if (!isEmpty())
{
if (front == rear)
{
front = 0;
rear = -1;
}
else
{
front++;
}
}
}
template<class T>
T queue<T>::peek()
{
if (!isEmpty())
{
T T1 = array[front];
return T1;
}
else
{
cout << "Queue is empty." << endl;
}
}
template<class T>
int queue<T>::GetCurrentSize()
{
return rear + 1;
}