-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueue.cpp
More file actions
68 lines (58 loc) · 988 Bytes
/
queue.cpp
File metadata and controls
68 lines (58 loc) · 988 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
#include "queue.h"
template<typename T>
Queue<T>::Queue(){
head = new Node<T>;
tail = head;
tail->next = NULL;
}
template<typename T>
Queue<T>::Queue(const T &data)
{
head = new Node<T>;
head->info = data;
tail = new Node<T>;
head->next = tail;
tail->next = NULL;
}
template<typename T>
bool Queue<T>::EnQueue(const T &data)
{
tail->info = data;
Node<T> *p;
p = new Node<T>;
p->next = NULL;
tail->next = p;
tail = p;
//cout<<"head: "<<head->info<<endl;
return true;
}
template<typename T>
bool Queue<T>::IsEmpty()
{
if(head == tail)
return true;
return false;
}
template<typename T>
T Queue<T>::GetQueue()
{
T data = head->info;
Node<T> *p;
p = head;
head = head->next;
delete p;
return data;
}
template<typename T>
T Queue<T>::GetHead()
{
T data = head->info;
return data;
}
template<typename T>
Queue<T>::~Queue()
{
}
template<typename T>
void Queue<T>::Test(){
}