A bit buffer allowing reading/writing of data a bit at a time.
Constructor and description |
---|
BitBuffer
(int bytes) Creates a bit buffer of a specfied size. |
Type Params | Return Type | Name and description |
---|---|---|
|
boolean |
eos() Checks if the read/write position is at the end of the buffer. |
|
byte[] |
getBytes() Gets an array of bytes in the buffer. |
|
int |
getSizeInBits() Gets the size of the buffer in bits. |
|
int |
getSizeInBytes() Gets the size of the buffer in bytes. |
|
int |
read() Reads one bit of data from the buffer. |
|
void |
reset() Resets the read/write position of the buffer to the start of the buffer. |
|
void |
write(int bit) Writes one bit into the buffer. |
|
void |
write(byte[] data) Writes an array of bytes into the buffer. |
Creates a bit buffer of a specfied size. The buffer size cannot be changed after allocation.
bytes
- number of bytes in the bufferChecks if the read/write position is at the end of the buffer.
Gets an array of bytes in the buffer. Any modifications to the array are reflected as changes in the buffer.
Gets the size of the buffer in bits.
Gets the size of the buffer in bytes.
Reads one bit of data from the buffer.
Resets the read/write position of the buffer to the start of the buffer.
Writes one bit into the buffer.
bit
- bit to write (0 or 1)Writes an array of bytes into the buffer. This method should not be called when an incompletely written byte exists in the buffer.
data
- array of bytes to writeCopyright 2013-19, Acoustic Research Laboratory, National University of Singapore, and Subnero Pte Ltd