public class FifoQueue<T> extends Object
Constructor and Description |
---|
FifoQueue()
Creates a FIFO queue with no elements enqueued.
|
FifoQueue(Collection<T> collection)
Creates a new FIFO queue containing the elements of the specified
Collection.
|
FifoQueue(T element)
Creates a new FIFO queue containing the argument to this constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(T element)
Indicate whether the specified element is currently in the queue.
|
boolean |
isEmpty()
Returns whether or not this queue is empty (no enqueued elements).
|
T |
peek()
Returns the next Object in the queue, but leaves it in the queue.
|
T |
pop()
Remove the next Object from the queue and return it to the caller.
|
void |
push(Iterator<? extends T> elements)
Insert all of the elements in the specified Iterator at the tail end of the
queue if not already present in the queue.
|
void |
push(T element)
Insert an Object at the tail end of the queue if it is not already in the
queue.
|
int |
size()
Return the current number of enqueued Objects, the number of Objects that
were pushed into the queue and have not been popped.
|
public FifoQueue()
public FifoQueue(T element)
element
- is the element to add to the queue.public FifoQueue(Collection<T> collection)
collection
- is the Collection of Object instances to be enqueue.IllegalArgumentException
- if collection is nullpublic int size()
isEmpty()
public boolean isEmpty()
true
when there are no enqueued objects.
false
if there are objects remaining in the queue.size()
public boolean contains(T element)
element
- determine whether this object is in the queue.true
if element
is in the queue.
Otherwise false
if not currently in the queue.public void push(T element)
This method determines whether an element is already in the queue using the
element's equals()
method. If the element's class does not
implement equals()
, the default implementation assumes they
are equal only if it is the same object.
element
- is the Object to be added to the queue if not already present in
the queue.public void push(Iterator<? extends T> elements) throws IllegalArgumentException
This method determines whether an element is already in the queue using the
element's equals()
method. If the element's class does not
implement equals()
, the default implementation assumes they
are equal if it is the same object.
elements
- an Iterator of Objects to be added to the queue if not already
queued.IllegalArgumentException
- if elements == nullpublic T pop() throws IllegalStateException
IllegalStateException
if the queue is empty when this method
is called.IllegalStateException
public T peek() throws IllegalStateException
IllegalStateException
if the queue is empty when this method
is called.IllegalStateException