T - The type of elements in the queue.java.lang.Iterable<T>, java.util.Collection<T>, java.util.Queue<T>public class EvictingQueue<T>
extends java.lang.Object
implements java.util.Queue<T>
EvictingQueue is a non-blocking queue which is limited to a maximum size; when new elements are added to a
full queue, elements are evicted from the head of the queue to accommodate the new elements.| Constructor | Description |
|---|---|
EvictingQueue(int maximumSize) |
Construct a new
EvictingQueue that holds maximumSize elements. |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(T t) |
Add the given element to the queue, possibly forcing an eviction from the head if
remainingCapacity() is
zero. |
boolean |
addAll(java.util.Collection<? extends T> c) |
Add the given elements to the queue, possibly forcing evictions from the head if
remainingCapacity() is
zero or becomes zero during the execution of this method. |
void |
clear() |
|
boolean |
contains(java.lang.Object o) |
|
boolean |
containsAll(java.util.Collection<?> c) |
|
T |
element() |
|
boolean |
isEmpty() |
|
java.util.Iterator<T> |
iterator() |
|
boolean |
offer(T t) |
|
T |
peek() |
|
T |
poll() |
|
int |
remainingCapacity() |
|
T |
remove() |
|
boolean |
remove(java.lang.Object o) |
|
boolean |
removeAll(java.util.Collection<?> c) |
|
boolean |
retainAll(java.util.Collection<?> c) |
|
int |
size() |
|
java.lang.Object[] |
toArray() |
|
<T1> T1[] |
toArray(T1[] a) |
public EvictingQueue(int maximumSize)
EvictingQueue that holds maximumSize elements.maximumSize - The maximum number of elements that the queue can holdjava.lang.IllegalArgumentException - if maximumSize is less than zeropublic int remainingCapacity()
public boolean add(T t)
remainingCapacity() is
zero.public boolean offer(T t)
offer in interface java.util.Queue<T>add(Object)public int size()
size in interface java.util.Collection<T>public boolean isEmpty()
isEmpty in interface java.util.Collection<T>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<T>public java.util.Iterator<T> iterator()
public java.lang.Object[] toArray()
toArray in interface java.util.Collection<T>public <T1> T1[] toArray(T1[] a)
toArray in interface java.util.Collection<T>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<T>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<T>public boolean addAll(java.util.Collection<? extends T> c)
remainingCapacity() is
zero or becomes zero during the execution of this method.addAll in interface java.util.Collection<T>c - the collection of elements to addpublic boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<T>public void clear()
clear in interface java.util.Collection<T>