-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.cpp
74 lines (68 loc) · 1.29 KB
/
queue.cpp
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
67
68
69
70
71
72
73
74
#include "ordering_structure.h"
/**
* @file queue.cpp
* Implementation of the Queue class.
*
*/
/**
* Adds the parameter object to the back of the Queue.
*
* @param newItem object to be added to the Queue.
*/
template <class T>
void Queue<T>::enqueue(T const& newItem)
{
myQueue.pushR(newItem);
}
/**
* Removes the object at the front of the Queue, and returns it to the
* caller.
*
* @return The item from the front of the Queue.
*/
template <class T>
T Queue<T>::dequeue()
{
return myQueue.popL();
}
/**
* Adds an element to the ordering structure.
*
* @see OrderingStructure::add()
*/
template <class T>
void Queue<T>::add(const T& theItem)
{
enqueue(theItem);
}
/**
* Removes an element from the ordering structure.
*
* @see OrderingStructure::remove()
*/
template <class T>
T Queue<T>::remove()
{
return dequeue();
}
/**
* Finds the object at the front of the Queue, and returns it to the
* caller. Unlike pop(), this operation does not alter the queue.
*
* @return The item at the front of the queue.
*/
template <class T>
T Queue<T>::peek()
{
return myQueue.peekL();
}
/**
* Determines if the Queue is empty.
*
* @return bool which is true if the Queue is empty, false otherwise.
*/
template <class T>
bool Queue<T>::isEmpty() const
{
return myQueue.isEmpty();
}