-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueSLL.h
More file actions
47 lines (41 loc) · 911 Bytes
/
Copy pathQueueSLL.h
File metadata and controls
47 lines (41 loc) · 911 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
#pragma
#include "SinglyLinkedList.h"
template <typename Type>
class QueueSLL
{
SinglyLinkedList <Type> List;
public:
int queue_size;
public:
QueueSLL() :queue_size(0){}
~QueueSLL(){}
QueueSLL(const QueueSLL<Type> & obj) :List(obj.List), queue_size(0){}
QueueSLL <Type> operator=(QueueSLL <Type> & RHS){ List = RHS.List; }
void Enqueue(const Type &item){
List.InsertAtEnd(item);
queue_size++;
}
Type Dequeue()
{
// if (List.IsEmpty())
bool IsValid = true;
Type a=List.Peak(IsValid);
if (IsValid == true)
{
List.DeleteAtStart();
queue_size--;
}
return a;
}
Type Peak(bool &IsValid){return List.Peak(IsValid);}
bool isEmpty(){ return List.IsEmpty(); }
void Clear(){ List.Clear(); }
void Print(){ List.Print(); }
bool Search(Type & item){ return List.Search(item);}
Type top()
{
bool flag=true;
return List.Peak(flag);
}
int size(){ return queue_size; }
};