-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.cpp
94 lines (87 loc) · 1.73 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* @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)
{
/**
* @todo Your code here!
*/
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()
{
/**
* @todo Your code here!
*/
return myQueue.popL();
}
/**
* Adds an element to the ordering structure.
*
* @see OrderingStructure::add()
*/
template <class T>
void Queue<T>::add(const T& theItem)
{
/**
* @todo Your code here! Hint: this function should call a Queue
* function to add the element to the Queue.
*/
enqueue(theItem);
}
/**
* Removes an element from the ordering structure.
*
* @see OrderingStructure::remove()
*/
template <class T>
T Queue<T>::remove()
{
/**
* @todo Your code here! Hint: this function should call a Queue
* function to remove an element from the Queue and return it.
*/
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()
{
/**
* @todo Your code here!
*/
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
{
/**
* @todo Your code here!
*/
return myQueue.isEmpty();
}