Class RotatingQueue<T>

java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractQueue<T>
org.assertj.core.presentation.RotatingQueue<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, Queue<T>

final class RotatingQueue<T> extends AbstractQueue<T>
Queue with a fixed maximum size. When an element is added to a full queue, the oldest element is removed before the new element is added.
  • Field Details

    • data

      private final Queue<T> data
      The array to provide a view of.
    • capacity

      private final int capacity
      The maximum number of elements that can be present.
  • Constructor Details

    • RotatingQueue

      RotatingQueue(int capacity)
      Creates a new RotatingQueue.
      Parameters:
      capacity - the maximum number of elements the queue can hold
      Throws:
      IllegalArgumentException - if the capacity is negative
  • Method Details