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>
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
-
Field Details
-
data
-
capacity
private final int capacityThe maximum number of elements that can be present.
-
-
Constructor Details
-
RotatingQueue
RotatingQueue(int capacity) Creates a newRotatingQueue.- Parameters:
capacity- the maximum number of elements the queue can hold- Throws:
IllegalArgumentException- if the capacity is negative
-
-
Method Details
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>
-
offer
-
poll
-
peek
-