Class FifoQueue<T>
java.lang.Object
com.ibm.wala.util.collections.FifoQueue<T>
- Direct Known Subclasses:
FifoQueueNoDuplicates
FIFO work queue management of Objects that prevents an object from being added to the queue if it
is already enqueued and has not yet been popped.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicate whether the specified element is currently in the queue.boolean
isEmpty()
Returns whether or not this queue is empty (no enqueued elements).peek()
Returns the next Object in the queue, but leaves it in the queue.pop()
Remove the next Object from the queue and return it to the caller.void
Insert all of the elements in the specified Iterator at the tail end of the queue if not already present in the queue.void
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.
-
Constructor Details
-
FifoQueue
public FifoQueue()Creates a FIFO queue with no elements enqueued. -
FifoQueue
Creates a new FIFO queue containing the argument to this constructor.- Parameters:
element
- is the element to add to the queue.
-
FifoQueue
Creates a new FIFO queue containing the elements of the specified Collection. The order the elements are inserted into the queue is unspecified.- Parameters:
collection
- is the Collection of Object instances to be enqueue.- Throws:
IllegalArgumentException
- if collection is null
-
-
Method Details
-
size
public int size()Return the current number of enqueued Objects, the number of Objects that were pushed into the queue and have not been popped.- Returns:
- the current queue size.
- See Also:
-
isEmpty
public boolean isEmpty()Returns whether or not this queue is empty (no enqueued elements).- Returns:
true
when there are no enqueued objects.false
if there are objects remaining in the queue.- See Also:
-
contains
Indicate whether the specified element is currently in the queue.- Parameters:
element
- determine whether this object is in the queue.- Returns:
true
ifelement
is in the queue. Otherwisefalse
if not currently in the queue.
-
push
Insert an Object at the tail end of the queue if it is not already in the queue. If the Object is already in the queue, the queue remains unmodified.This method determines whether an element is already in the queue using the element's
equals()
method. If the element's class does not implementequals()
, the default implementation assumes they are equal only if it is the same object.- Parameters:
element
- is the Object to be added to the queue if not already present in the queue.
-
push
Insert all of the elements in the specified Iterator at the tail end of the queue if not already present in the queue. Any element in the Iterator already in the queue is ignored.This method determines whether an element is already in the queue using the element's
equals()
method. If the element's class does not implementequals()
, the default implementation assumes they are equal if it is the same object.- Parameters:
elements
- an Iterator of Objects to be added to the queue if not already queued.- Throws:
IllegalArgumentException
- if elements == null
-
pop
Remove the next Object from the queue and return it to the caller. ThrowsIllegalStateException
if the queue is empty when this method is called.- Returns:
- the next Object in the queue.
- Throws:
IllegalStateException
-
peek
Returns the next Object in the queue, but leaves it in the queue. ThrowsIllegalStateException
if the queue is empty when this method is called.- Returns:
- the next Object in the queue.
- Throws:
IllegalStateException
-