-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathADTQueue.cpp
More file actions
42 lines (38 loc) · 701 Bytes
/
Copy pathADTQueue.cpp
File metadata and controls
42 lines (38 loc) · 701 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
#ifndef _ADTQUEUE
#define _ADTQUEUE 1
#include "ADTList.cpp"
template<typename T>
class Queue{
public:
Queue(){}
~Queue(){}
void clear(){
elem.clear();
}
bool empty(){
return elem.empty();
}
int length(){
return elem.length();
}
status getHead(T &e){
if(not length()) return ERROR;
e=*elem.begin();
return OK;
}
void traverse(){
elem.traverse();
}
void push(T e){
elem.insert(elem.end(),e);
}
status pop(T &e){
if(not length()) return ERROR;
e=*elem.begin();
elem.erase(elem.begin());
return OK;
}
private:
LinkList<T>elem;
};
#endif