class CircularBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer
The buffer
|
private int |
readIndex
Index of the next data to be read from the buffer
|
private int |
size
Size of the buffer
|
private int |
writeIndex
Index of the next data written in the buffer
|
Constructor and Description |
---|
CircularBuffer(int size) |
Modifier and Type | Method and Description |
---|---|
boolean |
available()
Tells if a new byte can be read from the buffer.
|
void |
copy(int distance,
int length)
Copy a previous interval in the buffer to the current position.
|
int |
get()
Reads a byte from the buffer.
|
void |
put(int value)
Writes a byte to the buffer.
|
private final int size
private final byte[] buffer
private int readIndex
private int writeIndex
public boolean available()
public void put(int value)
public int get()
public void copy(int distance, int length)
distance
- the distance from the current write positionlength
- the number of bytes to copy