java.lang.Object
org.jgroups.raft.util.ArrayRingBuffer<T>
It's a growable ring buffer that allows to move tail/head sequences, clear, append, set/replace at specific positions.
- Author:
- Francesco Nigro
-
Constructor Summary
ConstructorsConstructorDescriptionArrayRingBuffer(int initialSize, long headSequence) ArrayRingBuffer(long headSequence) -
Method Summary
Modifier and TypeMethodDescriptionvoidintvoidclear()booleancontains(long index) intdropHeadUntil(long indexExclusive) Remove all elements fromheadSequencetoindexExclusive.
At the end of this operationheadSequenceis equals toindexExclusive.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 headremove(long index) Removes an element at indexintsize()intsize(boolean count_null_elements) toString()
-
Constructor Details
-
ArrayRingBuffer
public ArrayRingBuffer() -
ArrayRingBuffer
public ArrayRingBuffer(long headSequence) -
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.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 fromheadSequencetoindexExclusive.
At the end of this operationheadSequenceis equals toindexExclusive.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 -
remove
Removes an element at index -
toString
-