Package org.apache.flink.runtime.util
Class BoundedFIFOQueue<T>
java.lang.Object
org.apache.flink.runtime.util.BoundedFIFOQueue<T>
- Type Parameters:
T- The type of elements collected.
- All Implemented Interfaces:
Serializable,Iterable<T>
BoundedFIFOQueue collects elements up to given amount. Reaching this limit will result in
removing the oldest element from this queue (First-In/First-Out; FIFO).- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBoundedFIFOQueue(int maxSize) Creates aBoundedFIFOQueuewith the given maximum size. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BoundedFIFOQueue
public BoundedFIFOQueue(int maxSize) Creates aBoundedFIFOQueuewith the given maximum size.- Parameters:
maxSize- The maximum size of this queue. Exceeding this limit would result in removing the oldest element (FIFO).- Throws:
IllegalArgumentException- IfmaxSizeis less than 0.
-
-
Method Details
-
add
Adds an element to the end of the queue. An element will be removed from the head of the queue if the queue would exceed its maximum size by adding the new element.- Parameters:
element- The element that should be added to the end of the queue.- Throws:
NullPointerException- Ifnullis passed as an element.
-
toArrayList
-
size
public int size()Returns the number of currently stored elements.- Returns:
- The number of currently stored elements.
-
iterator
Returns theBoundedFIFOQueue'sIterator.
-