-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.cpp
51 lines (48 loc) · 1023 Bytes
/
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
/**
* @file queue.cpp
* Implementation of the Queue class.
*
*/
//treat the right hand side as the back of the queue
/**
* 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 newItem)
{
myQueue.pushR(newItem);
}
/**
* Removes the object at the front of the Queue, and returns it to the
* caller.
*
* @return The item that used to be at the front of the Queue.
*/
template <class T>
T Queue<T>::dequeue()
{
return myQueue.popL();
}
/**
* Finds the object at the front of the Queue, and returns it to the
* caller. Unlike dequeue(), 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();
}