Class RingBuffer<T>
- java.lang.Object
-
- org.craftercms.studio.impl.v2.utils.RingBuffer<T>
-
- Type Parameters:
T
- type of objects to store
public class RingBuffer<T> extends Object
A special ring buffer implementation that allows unlimited writes keeping only a preset size of buffer, followed by reading of what was written in the order it was written ignoring what was overwritten when writing beyond the preset size. This means you always read the least recently written item. This data structure cannot be written to once reading has begun.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
readCursor
protected T[]
ringBuffer
protected int
size
protected int
writeCursor
-
Constructor Summary
Constructors Constructor Description RingBuffer(int size)
-