Package org.apache.druid.utils
Class CircularBuffer<E>
- java.lang.Object
-
- org.apache.druid.utils.CircularBuffer<E>
-
- Type Parameters:
E
- Type of object to be stored in the buffer
public class CircularBuffer<E> extends Object
A circular buffer that supports random bidirectional access.
-
-
Constructor Summary
Constructors Constructor Description CircularBuffer(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(E item)
E
get(int index)
Access object at a given index, starting from the earliest entry added and moving forward.E[]
getBuffer()
E
getLatest(int index)
Access object at a given index, starting from the latest entry added and moving backwards.int
size()
-
-
-
Method Detail
-
getBuffer
public E[] getBuffer()
-
add
public void add(E item)
-
getLatest
public E getLatest(int index)
Access object at a given index, starting from the latest entry added and moving backwards.
-
get
public E get(int index)
Access object at a given index, starting from the earliest entry added and moving forward.
-
size
public int size()
-
-