public class ByteRingBuffer extends RingBuffer
RingBuffer
of a byte[].Constructor and Description |
---|
ByteRingBuffer(byte[] buffer)
Constructs a ring buffer over an existing byte[].
|
ByteRingBuffer(int capacity)
Constructs a ring buffer over an implicitly allocated byte[].
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getBuffer()
Gets the underlying byte[].
|
int |
peek(int delta)
Gets the byte at a given relative position ahead of the current virtual read position.
|
int |
read()
Reads the byte at the virtual read position, and advances the virtual read position by 1.
|
int |
write(byte b)
Writes a byte at the virtual write position, and advances the virtual write position by 1.
|
advanceReadPosition, advanceWritePosition, getAvailableToRead, getAvailableToReadStraight, getAvailableToWrite, getAvailableToWriteStraight, getBufferLength, getReadPosition, getTotalReadCount, getTotalWriteCount, getWritePosition, isEOF, setEOF
public ByteRingBuffer(int capacity)
capacity
- Capacity of the implicit byte[].public ByteRingBuffer(byte[] buffer)
buffer
- An existing byte[].public byte[] getBuffer()
RingBuffer.getAvailableToReadStraight()
or RingBuffer.getAvailableToWriteStraight()
.public int peek(int delta)
delta
- A relative position ahead of the virtual read position to peek at.RingBuffer.getAvailableToRead()
.public int read()
public int write(byte b)
b
- Byte to be written.