-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQueue.h
More file actions
62 lines (44 loc) · 1.25 KB
/
Queue.h
File metadata and controls
62 lines (44 loc) · 1.25 KB
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
#ifndef QUETYPE_H
#define QUETYPE_H
class FullQueue {
};
class EmptyQueue {
};
template<class T>
class Queue {
public:
Queue();
// Default constructors
explicit Queue(int max);
// Parameterized class constructor.
~Queue();
// Class destructor.
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(T 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.
T Dequeue();
// 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
// returns a copy of removed element.
private:
struct Node {
Node* next;
T value;
};
Node* head;
Node* tail;
};
#include "Queue.cpp"
#endif