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:
  • Constructor Details

    • BoundedFIFOQueue

      public BoundedFIFOQueue(int maxSize)
      Creates a BoundedFIFOQueue 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 - If maxSize is less than 0.
  • Method Details

    • 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 - If null is passed as an element.
    • toArrayList

      public ArrayList<T> toArrayList()
    • size

      public int size()
      Returns the number of currently stored elements.
      Returns:
      The number of currently stored elements.
    • iterator

      public Iterator<T> iterator()
      Returns the BoundedFIFOQueue's Iterator.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      The queue's Iterator.