forked from ArsalanKhairani/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayQueue.h
57 lines (48 loc) · 1.2 KB
/
ArrayQueue.h
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
/*******************************************************************************
* Copyright(c) Arsalan Khairani, 2014 *
* Queue *
* Using Array *
* *
* Generic array implementation of Queue. *
* Based on Array List implementation. *
*******************************************************************************/
#pragma once
#include "arraylist.h"
template < typename ARRAYTYPE >
class ArrayQueue :
public ArrayList<ARRAYTYPE>
{
int total;
int filled;
public:
ArrayQueue(void)
{
total = 10;
filled = 0;
array = new (ARRAYTYPE [total]);
}
//add an item to the top of the queue
void Enqueue(ARRAYTYPE item)
{
InsertItem(filled, item);
filled++;
}
//remove an item from the bottom of the queue
void Dequeue()
{
DeleteItem(0);
filled--;
}
//display whole array Queue
void DisplayArrayQueue()
{
cout << endl;
for (int i = filled -1; i>=0; i--)
{
cout << array[i] << " ";
}
}
~ArrayQueue(void)
{
}
};