-
Method Summary
void
Adds a new entry to the back of this dequeue.
void
Adds a new entry to the front of this dequeue.
void
Removes all entries from the dequeue.
Retrieves the element at the back of this dequeue.
Retrieves the element at the front of this dequeue.
boolean
Determines if there are any elements in the dequeue.
Removes and returns the element at the back of the dequeue.
Removes and returns the element at the front of the dequeue.
-
Method Details
-
addToFront
void addToFront(T element)
Adds a new entry to the front of this dequeue.
- Parameters:
element
- element to be added to the dequeue
-
addToBack
void addToBack(T element)
Adds a new entry to the back of this dequeue.
- Parameters:
element
- element to be added to the dequeue
-
removeFront
Removes and returns the element at the front of the dequeue.
The size of the dequeue is decreased by one.
- Returns:
- The element at the front of the dequeue
- Throws:
EmptyQueueException
- if the dequeue is empty when the method is invoked
-
removeBack
Removes and returns the element at the back of the dequeue.
The size of the dequeue is decreased by one.
- Returns:
- The element at the back of the dequeue
- Throws:
EmptyQueueException
- if the dequeue is empty when the method is invoked
-
getFront
Retrieves the element at the front of this dequeue.
The size of the dequeue is not changed.
- Specified by:
getFront
in interface QueueInterface<T>
- Returns:
- The element at the front of the dequeue.
- Throws:
EmptyQueueException
- if the dequeue is empty when the method is invoked
-
getBack
Retrieves the element at the back of this dequeue.
The size of the dequeue is not changed.
- Returns:
- The element at the back of the dequeue.
- Throws:
EmptyQueueException
- if the dequeue is empty when the method is invoked
-
isEmpty
boolean isEmpty()
Determines if there are any elements in the dequeue.
- Specified by:
isEmpty
in interface QueueInterface<T>
- Returns:
- True if the dequeue is empty.
-
clear
void clear()
Removes all entries from the dequeue.
- Specified by:
clear
in interface QueueInterface<T>