public class Bits
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private int |
bitPtr
Position of the bit "cursor" within the current byte
|
private int |
bytePtr
Position of the byte "cursor"
|
private byte[] |
bytes
"raw" data
|
static int |
DEFAULT_BUFFER_SIZE
Default buffer size
|
| Constructor and Description |
|---|
Bits() |
| Modifier and Type | Method and Description |
|---|---|
void |
advance(int n)
Advance n bits.
|
byte[] |
getBuffer()
Returns the current buffer array.
|
int |
getBufferSize()
Returns the number of bytes used in the current buffer.
|
void |
init()
Initialise the bit packing variables.
|
void |
pack(int data,
int nbBits)
Write N bits of the given data to the buffer.
|
int |
peek()
Take a peek at the next bit.
|
void |
read_from(byte[] newbytes,
int offset,
int len)
Read the given array into the buffer.
|
protected void |
setBuffer(byte[] newBuffer)
Sets the buffer to the given value.
|
int |
unpack(int nbBits)
Read the next N bits from the buffer.
|
public static final int DEFAULT_BUFFER_SIZE
private byte[] bytes
private int bytePtr
private int bitPtr
public void init()
public void advance(int n)
n - - the number of bits to advance.protected void setBuffer(byte[] newBuffer)
newBuffer - public int peek()
public void read_from(byte[] newbytes,
int offset,
int len)
newbytes - offset - len - public int unpack(int nbBits)
nbBits - - the number of bits to read.public void pack(int data,
int nbBits)
data - - the data to write.nbBits - - the number of bits of the data to write.public byte[] getBuffer()
public int getBufferSize()
Copyright © 1999-2004 Wimba S.A. All Rights Reserved.