Class ArrayRingBuffer<T>

java.lang.Object
org.jgroups.raft.util.ArrayRingBuffer<T>

public final class ArrayRingBuffer<T> extends Object
It's a growable ring buffer that allows to move tail/head sequences, clear, append, set/replace at specific positions.
Author:
Francesco Nigro
  • 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

      public void forEach(ObjLongConsumer<? super T> consumer)
    • 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 from tailSequence back to indexInclusive.
      At the end of this operation tailSequence is equals to indexInclusive.
       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 from headSequence to indexExclusive.
      At the end of this operation headSequence is equals to indexExclusive.
       eg:
       elements = [A, B, C]
       tail = 3
       head = 0
      
       dropHeadUntil(1)
      
       elements = [B, C]
       tail = 3
       head = 1
       
    • get

      public T get(long index)
    • set

      public T set(long index, T e)
    • add

      public void add(T e)
    • isEmpty

      public boolean isEmpty()
    • peek

      public T peek()
    • poll

      public T poll()
      Removes the element at head
    • remove

      public T remove(long index)
      Removes an element at index
    • toString

      public String toString()
      Overrides:
      toString in class Object