public abstract class RollingBuffer<T extends RollingBuffer.Resettable>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
RollingBuffer.Resettable
Implement to reset an instance
|
Modifier and Type | Field and Description |
---|---|
private T[] |
buffer |
private int |
count |
private int |
nextPos |
private int |
nextWrite |
Constructor and Description |
---|
RollingBuffer() |
Modifier and Type | Method and Description |
---|---|
void |
freeBefore(int pos) |
T |
get(int pos)
Get T instance for this absolute position;
this is allowed to be arbitrarily far "in the
future" but cannot be before the last freeBefore.
|
int |
getBufferSize()
Returns how many active positions are in the buffer.
|
private int |
getIndex(int pos) |
int |
getMaxPos()
Returns the maximum position looked up, or -1 if no
position has been looked up since reset/init.
|
private boolean |
inBounds(int pos) |
protected abstract T |
newInstance() |
void |
reset() |
private T extends RollingBuffer.Resettable[] buffer
private int nextWrite
private int nextPos
private int count
protected abstract T newInstance()
public void reset()
private boolean inBounds(int pos)
private int getIndex(int pos)
public T get(int pos)
public int getMaxPos()
public int getBufferSize()
public void freeBefore(int pos)