-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminiQueue.h
66 lines (58 loc) · 1.69 KB
/
miniQueue.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
57
58
59
60
61
62
63
64
65
66
#ifndef MINIQUEUE_H
#define MINIQUEUE_H
using namespace std;
template <class DataType>
class miniArrQueue {
private:
//For Array:
DataType *arr; //array of items
int capacity; //Size
int front; //location of front
int rear; //location of end
int count; //size of queue
public:
miniArrQueue(); //constructor
miniArrQueue(const miniArrQueue &); //copy
~miniArrQueue(); //destructor
int size () const; //return size
bool isEmpty() const; //Check if empty
void enqueue(const DataType &e);//Add to end
void dequeue(); //Remove front
const DataType& getfront() const; //returns front
void printQueue () const; //Print from front to rear
miniArrQueue<DataType>& operator=(const miniArrQueue<DataType>&);
// Assignment operator
//Bonus:
friend ostream& operator << (ostream& os, const miniArrQueue<DataType>& q) {
for (int i = 0; i < q.count; i++)
os << q.arr[i] << "\n";
os << "\n";
return os;
}
};
#include "miniDList.h"
template <class DataType>
class miniListQueue {
private:
//For lists:
miniDList<DataType> list;
public:
miniListQueue(); //constructor
miniListQueue(const miniListQueue &); //copy
~miniListQueue(); //destructor
int size () const; //return size
bool isEmpty() const; //Check if empty
void enqueue(const DataType &e);//Add to end
void dequeue(); //Remove front
const DataType& getfront() const; //returns front
void printQueue () const; //Print from front to rear
miniListQueue<DataType>& operator=(const miniListQueue<DataType>&);
//Assignment operator
//Bonus:
friend ostream& operator << (ostream& os, const miniListQueue<DataType>& q) {
os << q.list << "\n";
return os;
}
};
#include "miniQueue.cpp"
#endif