|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjist.swans.trans.CircularBuffer
public class CircularBuffer
A class that implements circular byte array.
| Field Summary | |
|---|---|
private byte[] |
buffer
Array to hold the bytes. |
private int |
curSize
current size of the buffer. |
private int |
head
points to first unread byte. |
private boolean |
isBufferEmpty
Indicator that buffer is empty. |
private boolean |
isBufferFull
Indicator that buffer is full. |
private int |
tail
points to the byte after the last unread byte. |
| Constructor Summary | |
|---|---|
CircularBuffer(int size)
Constructor. |
|
| Method Summary | |
|---|---|
int |
getCurrentBufferSize()
Returns the buffer size. |
int |
getFreeBufferSize()
Returns the free space in buffer. |
int |
getTotalBytesInBuffer()
Returns the number of bytes stored in buffer. |
boolean |
isBufferEmpty()
Check if buffer is empty. |
boolean |
isBufferFull()
Check if buffer is full. |
byte[] |
peekOneByte()
Peek the next byte in buffer. |
boolean |
resizeBuffer(int newSize)
Resize the buffer to the specified value. |
byte[] |
retrieveAllBytes()
Retrieves all of the bytes stored in the buffer. |
byte[] |
retrieveBytes(int length)
Retrieves the specific number of bytes. |
int |
storeBytes(byte[] data)
Store the byte array into the buffer. |
int |
storeBytes(byte[] data,
int offset,
int length)
Store the byte array from specific offset and length into the buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private byte[] buffer
private int curSize
private int head
private int tail
private boolean isBufferFull
private boolean isBufferEmpty
| Constructor Detail |
|---|
public CircularBuffer(int size)
size - size of the buffer| Method Detail |
|---|
public int storeBytes(byte[] data)
data - byte array
public int storeBytes(byte[] data,
int offset,
int length)
data - byte arrayoffset - offset in data to start readinglength - number of bytes to store
public byte[] retrieveBytes(int length)
length - number of bytes
public byte[] retrieveAllBytes()
public byte[] peekOneByte()
public int getFreeBufferSize()
public int getTotalBytesInBuffer()
public int getCurrentBufferSize()
public boolean resizeBuffer(int newSize)
newSize - new size of the buffer
public boolean isBufferFull()
public boolean isBufferEmpty()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||