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>
public class BoundedFIFOQueue<T> extends Object implements Iterable<T>, Serializable
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BoundedFIFOQueue(int maxSize)
Creates aBoundedFIFOQueue
with the given maximum size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T element)
Adds an element to the end of the queue.Iterator<T>
iterator()
Returns theBoundedFIFOQueue
'sIterator
.int
size()
Returns the number of currently stored elements.ArrayList<T>
toArrayList()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
BoundedFIFOQueue
public BoundedFIFOQueue(int maxSize)
Creates aBoundedFIFOQueue
with 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
- IfmaxSize
is less than 0.
-
-
Method Detail
-
add
public void add(T element)
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
- Ifnull
is passed as an element.
-
size
public int size()
Returns the number of currently stored elements.- Returns:
- The number of currently stored elements.
-
-