public class CharRingBuffer extends RingBuffer
RingBuffer
of a char[].Constructor and Description |
---|
CharRingBuffer(char[] buffer)
Constructs a ring buffer over an existing char[].
|
CharRingBuffer(int capacity)
Constructs a ring buffer over an implicitly allocated char[].
|
Modifier and Type | Method and Description |
---|---|
char[] |
getBuffer()
Gets the underlying char[].
|
int |
peek(int delta)
Gets the char at a given relative position ahead of the current virtual read position.
|
int |
read()
Reads the char at the virtual read position, and advances the virtual read position by 1.
|
int |
write(char c)
Writes a char 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 CharRingBuffer(int capacity)
capacity
- Capacity of the implicit char[].public CharRingBuffer(char[] buffer)
buffer
- An existing char[].public char[] 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(char c)
c
- Char to be written.