T - type of objects stored@ThreadSafe public class SynchronizedEvictingRingBuffer<T> extends EvictingRingBuffer<T>
| Constructor and Description |
|---|
SynchronizedEvictingRingBuffer(int capacity) |
SynchronizedEvictingRingBuffer(int capacity,
boolean throwOnOverflow) |
SynchronizedEvictingRingBuffer(int capacity,
boolean throwOnOverflow,
T defaultValue) |
SynchronizedEvictingRingBuffer(int capacity,
T defaultValue) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T value)
Add a value at the end of the ring buffer.
|
boolean |
addAll(Collection<? extends T> coll) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> coll) |
T |
element()
Retrieves, but does not remove, the head of this buffer.
|
boolean |
equals(Object obj) |
void |
forEach(java.util.function.Consumer<? super T> consumer) |
T |
get(int index)
Return the element at the specified position in the buffer.
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
offer(T value)
Inserts the specified element into this queue if it is possible to do so
immediately without violating capacity restrictions.
|
T |
peek()
Retrieves, but does not remove, the head of this buffer, or returns null if empty.
|
T |
poll()
Retrieves and removes the head of this buffer, or returns null if empty.
|
T |
remove()
Retrieves and removes the head of this buffer.
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> coll) |
boolean |
removeIf(java.util.function.Predicate<? super T> filter) |
boolean |
retainAll(Collection<?> coll) |
int |
size()
Returns number of elements in the buffer.
|
Object[] |
toArray() |
<U> U[] |
toArray(U[] a) |
List<T> |
toList()
Returns a
List<T> containing all the elements in the buffer
in proper sequence (first to last element). |
String |
toString() |
capacity, clone, iteratorfinalize, getClass, notify, notifyAll, wait, wait, waitparallelStream, spliterator, streampublic SynchronizedEvictingRingBuffer(int capacity)
capacity - desired capacity.public SynchronizedEvictingRingBuffer(int capacity,
boolean throwOnOverflow)
capacity - desired capacitythrowOnOverflow - Disables auto-eviction on overflow. When full capacity is
reached, all subsequent append() operations would throw
IllegalStateException if this parameter is true,
or evict the oldest value if this parameter is false.public SynchronizedEvictingRingBuffer(int capacity,
@Nullable
T defaultValue)
capacity - desired capacity.defaultValue - pre-fill the buffer with this default value.public SynchronizedEvictingRingBuffer(int capacity,
boolean throwOnOverflow,
@Nullable
T defaultValue)
capacity - desired capacity.throwOnOverflow - disables auto-eviction on overflow. When full capacity is
reached, all subsequent append() operations would throw
IllegalStateException if this parameter is true,
or evict the oldest value if this parameter is false.defaultValue - pre-fill the buffer with this default value.public int size()
EvictingRingBuffersize in interface Collection<T>size in class EvictingRingBuffer<T>public T get(int index)
EvictingRingBufferget in class EvictingRingBuffer<T>index - index of the element to returnpublic boolean add(T value)
EvictingRingBufferadd in interface Collection<T>add in interface Queue<T>add in class EvictingRingBuffer<T>value - element to be appended to the end of the bufferCollection#add(T))public boolean offer(T value)
EvictingRingBufferpublic List<T> toList()
EvictingRingBufferList<T> containing all the elements in the buffer
in proper sequence (first to last element).toList in class EvictingRingBuffer<T>List<T> containing all the elements in the buffer
in proper sequence@Nonnull public Object[] toArray()
toArray in interface Collection<T>toArray in class EvictingRingBuffer<T>public T remove()
EvictingRingBufferpublic T poll()
EvictingRingBufferpublic T element()
EvictingRingBufferpublic T peek()
EvictingRingBufferpublic boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in class AbstractCollection<T>public boolean contains(Object o)
contains in interface Collection<T>contains in class AbstractCollection<T>public boolean containsAll(@Nonnull Collection<?> coll)
containsAll in interface Collection<T>containsAll in class AbstractCollection<T>public boolean addAll(@Nonnull Collection<? extends T> coll)
addAll in interface Collection<T>addAll in class AbstractCollection<T>public boolean removeAll(@Nonnull Collection<?> coll)
removeAll in interface Collection<T>removeAll in class AbstractCollection<T>public boolean retainAll(@Nonnull Collection<?> coll)
retainAll in interface Collection<T>retainAll in class AbstractCollection<T>public void clear()
clear in interface Collection<T>clear in class AbstractCollection<T>public String toString()
toString in class AbstractCollection<T>public void forEach(java.util.function.Consumer<? super T> consumer)
public boolean removeIf(java.util.function.Predicate<? super T> filter)
public boolean remove(Object o)
remove in interface Collection<T>remove in class AbstractCollection<T>public int hashCode()
hashCode in interface Collection<T>hashCode in class EvictingRingBuffer<T>public boolean equals(Object obj)
equals in interface Collection<T>equals in class EvictingRingBuffer<T>@Nonnull public <U> U[] toArray(@Nonnull U[] a)
toArray in interface Collection<T>toArray in class AbstractCollection<T>Copyright © 2020. All rights reserved.