-
Notifications
You must be signed in to change notification settings - Fork 0
/
QueueAr.h
45 lines (37 loc) · 1.15 KB
/
QueueAr.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
#ifndef _QUEUEAR_H
#define _QUEUEAR_H
#include "vector.h"
#include "dsexceptions.h"
// Queue class -- array implementation
//
// CONSTRUCTION: with or without a capacity; default is 10
//
// ******************PUBLIC OPERATIONS*********************
// void enqueue( x ) --> Insert x
// void dequeue( ) --> Return and remove least recently inserted item
// Object getFront( ) --> Return least recently inserted item
// bool isEmpty( ) --> Return true if empty; else false
// bool isFull( ) --> Return true if full; else false
// void makeEmpty( ) --> Remove all items
// ******************ERRORS********************************
// Overflow and Underflow thrown as needed
template <class Object>
class Queue
{
public:
explicit Queue( int capacity = 10 );
bool isEmpty( ) const;
bool isFull( ) const;
const Object & getFront( ) const;
void makeEmpty( );
Object dequeue( );
void enqueue( const Object & x );
private:
vector<Object> theArray;
int currentSize;
int front;
int back;
void increment( int & x );
};
#include "QueueAr.cpp"
#endif