-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueType.h
49 lines (45 loc) · 1.4 KB
/
QueType.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
// Header file for Queue ADT.
#include <new>
#include <cstddef>
class FullQueue
{};
class EmptyQueue
{};
typedef int ItemType;
struct NodeType;
class QueType
{
public:
QueType();
// Class constructor.
// Because there is a default constructor, the precondition
// that the queue has been initialized is omitted.
QueType(int max);
// Parameterized class constructor.
~QueType();
// Class destructor.
QueType(const QueType& anotherQue);
// Copy constructor
void MakeEmpty();
// Function: Initializes the queue to an empty state.
// Post: Queue is empty.
bool IsEmpty() const;
// Function: Determines whether the queue is empty.
// Post: Function value = (queue is empty)
bool IsFull() const;
// Function: Determines whether the queue is full.
// Post: Function value = (queue is full)
void Enqueue(ItemType newItem);
// Function: Adds newItem to the rear of the queue.
// Post: If (queue is full) FullQueue exception is thrown
// else newItem is at rear of queue.
void Dequeue(ItemType& item);
// Function: Removes front item from the queue and returns it in item.
// Post: If (queue is empty) EmptyQueue exception is thrown
// and item is undefined
// else front element has been removed from queue and
// item is a copy of removed element.
private:
NodeType* front;
NodeType* rear;
};