Package org.assertj.core.presentation
Class RotatingQueue<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<T>
-
- org.assertj.core.presentation.RotatingQueue<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Queue<T>
final class RotatingQueue<T> extends java.util.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.
-
-
Constructor Summary
Constructors Constructor Description RotatingQueue(int capacity)
Creates a newRotatingQueue
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator<T>
iterator()
boolean
offer(T element)
T
peek()
T
poll()
int
size()
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
data
private final java.util.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 Detail
-
RotatingQueue
RotatingQueue(int capacity)
Creates a newRotatingQueue
.- Parameters:
capacity
- the maximum number of elements the queue can hold- Throws:
java.lang.IllegalArgumentException
- if the capacity is negative
-
-