|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ikrs.io.CircularFIFO
public class CircularFIFO
The CircularFIFO implements an ... ehm ... yes, a circular FIFO buffer.
Constructor Summary | |
---|---|
CircularFIFO(int capacity)
Creates a new circular FIFO buffer. |
Method Summary | |
---|---|
int |
capacity()
Get the whole capacity for this buffer. |
void |
clear()
This method clears the buffer's data. |
boolean |
isEmpty()
Checks whether this buffer is empty. |
boolean |
isFull()
Checks whether this buffer is full. |
int |
length()
Get the number of bytes currently stored inside this buffer. |
static void |
main(java.lang.String[] argv)
|
byte |
peek(int offset)
Get the byte at the given buffer offset (relative). |
byte |
read()
Read a single byte from this buffer (if available). |
int |
read(byte[] buf,
int offset,
int readLength)
This method reads up to 'readLength' bytes from this buffer and stores them inside the given 'buf' array. |
java.lang.String |
toString()
|
java.lang.StringBuffer |
toString(java.lang.StringBuffer b)
|
void |
write(byte b)
This method writes the given byte to this buffer. |
int |
write(byte[] buf,
int offset,
int writeLength)
This method writes up tp 'writeLength' bytes bytes to this buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CircularFIFO(int capacity) throws java.lang.IllegalArgumentException
capacity
- The buffer's capacity (means: up to 'size' bytes can be stored in this buffer).
java.lang.IllegalArgumentException
Method Detail |
---|
public int capacity()
public int length()
public boolean isEmpty()
public boolean isFull()
public byte read() throws java.nio.BufferUnderflowException
java.nio.BufferUnderflowException
- If this buffer is empty [length()==0].public int read(byte[] buf, int offset, int readLength)
buf
- The byte buffer to read from.offset
- The read offset for the input array.readLength
- The max. number of bytes to read from the input array.
public void write(byte b) throws java.nio.BufferOverflowException
b
- The byte to write.
java.nio.BufferOverflowException
- If the buffer is already full and the byte cannot be written.public int write(byte[] buf, int offset, int writeLength)
public void clear()
public byte peek(int offset) throws java.lang.IndexOutOfBoundsException
offset
- The byte offset (0 <= offset < this.length()).
java.lang.IndexOutOfBoundsException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.StringBuffer toString(java.lang.StringBuffer b)
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |