Modifier and Type | Field and Description |
---|---|
private Deque<T> |
queue
Underlying queue.
|
private QueueType |
queueType
How will objects be inserted into the queue.
|
Constructor and Description |
---|
Queue(QueueType type)
Creates a new queue.
|
Modifier and Type | Method and Description |
---|---|
void |
add(T t)
Adds an object to the queue based on the queue type.
|
boolean |
contains(T t)
Returns whether t is in the queue.
|
T |
element()
Retrieves, but does not remove, the first element in the queue.
|
boolean |
isEmpty()
Returns whether or not the queue is empty.
|
Iterator<T> |
iterator() |
T |
remove()
Removes the first element in the queue.
|
boolean |
remove(T t)
Removes the supplied element from the queue.
|
int |
size()
Returns the number of elements in the queue.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
private final QueueType queueType
public Queue(QueueType type)
type
- how will objects be inserted into the queuepublic void add(T t)
Deque.offerFirst(Object)
and Deque.offerLast(Object)
.t
- to addpublic T remove()
Deque.removeFirst()
.public boolean remove(T t)
Deque.remove(Object)
.t
- to removepublic T element()
Deque.getFirst()
.public boolean contains(T t)
Deque.contains(Object)
.t
- that may be in the queuepublic boolean isEmpty()
Collection.isEmpty()
}.public int size()
Deque.size()
.Copyright © 2003-2019 Virginia Tech. All Rights Reserved.