Class ArrayRingBuffer<T>
java.lang.Object
org.infinispan.commons.util.ArrayRingBuffer<T>
It's a growable ring buffer that allows to move tail/head sequences, clear, append, set/replace at specific positions.
This version requires headSequence to always be pointing at the first non null value if one is present.
- Author:
- Francesco Nigro
-
Constructor Summary
ConstructorsConstructorDescriptionArrayRingBuffer(int initialSize) ArrayRingBuffer(int initialSize, long headSequence) -
Method Summary
Modifier and TypeMethodDescriptionvoidintvoidclear()booleancontains(long index) intdropHeadUntil(long indexExclusive) Remove all elements fromheadSequenceto at leastindexExclusiveuntil a non null value is found if present.
At the end of this operationheadSequencewill be greater than or equalindexExclusive.intdropTailTo(long indexInclusive) Remove all elements fromtailSequenceback toindexInclusive.
At the end of this operationtailSequenceis equals toindexInclusive.voidvoidforEach(ObjLongConsumer<? super T> consumer) get(long index) longlongbooleanisEmpty()peek()poll()Removes the element at head, does not catch up the headSequence but will incrementremove(long index) Removes an element at indexintsize()intsize(boolean count_null_elements) toString()
-
Constructor Details
-
ArrayRingBuffer
public ArrayRingBuffer() -
ArrayRingBuffer
public ArrayRingBuffer(int initialSize) -
ArrayRingBuffer
public ArrayRingBuffer(int initialSize, long headSequence)
-
-
Method Details
-
size
public int size() -
size
public int size(boolean count_null_elements) -
getTailSequence
public long getTailSequence() -
getHeadSequence
public long getHeadSequence() -
forEach
-
availableCapacityWithoutResizing
public int availableCapacityWithoutResizing() -
contains
public boolean contains(long index) -
dropTailToHead
public void dropTailToHead() -
clear
public void clear() -
dropTailTo
public int dropTailTo(long indexInclusive) Remove all elements fromtailSequenceback toindexInclusive.
At the end of this operationtailSequenceis equals toindexInclusive. Note there can be null values betweentailSequenceandheadSequenceas onlyheadSequenceis caught up to a non null value on modification.eg: elements = [A, B, C] tail = 3 head = 0 dropTailTo(1) elements = [A] tail = 1 head = 0
-
dropHeadUntil
public int dropHeadUntil(long indexExclusive) Remove all elements fromheadSequenceto at leastindexExclusiveuntil a non null value is found if present.
At the end of this operationheadSequencewill be greater than or equalindexExclusive. If there are no more values left thenheadSequencewill equaltailSequence.eg: elements = [A, B, C] tail = 3 head = 0 dropHeadUntil(1) elements = [B, C] tail = 3 head = 1
-
get
-
set
-
add
-
isEmpty
public boolean isEmpty() -
peek
-
poll
Removes the element at head, does not catch up the headSequence but will increment -
remove
Removes an element at index -
toString
-