public class BitArray extends Object
Constructor and Description |
---|
BitArray(byte b)
Constructs a new
BitArray by using the specified byte. |
BitArray(byte[] bytes)
Constructs a new
BitArray by using the specified array of bytes. |
BitArray(byte[] bytes,
int offset,
int length)
Constructs a new
BitArray by using the specified subarray of bytes. |
BitArray(int length)
Initializes a newly created
BitArray object so that it represents
an bit sequence which all bits is not set. |
Modifier and Type | Method and Description |
---|---|
void |
clearBit(int position)
Clear the specified bit.
|
byte[] |
getBytes()
Returns this sequence of bits into an array of bytes.
|
void |
setBit(int position)
Set the specified bit.
|
boolean |
testBit(int position)
Tests if the specified bit is set or not.
|
public BitArray(byte b)
BitArray
by using the specified byte.b
- The byte to use.public BitArray(byte[] bytes)
BitArray
by using the specified array of bytes.bytes
- The bytes to use.public BitArray(byte[] bytes, int offset, int length)
BitArray
by using the specified subarray of bytes.bytes
- The bytes to use.offset
- The index of the first byte to uselength
- The number of bytes to useIndexOutOfBoundsException
- If the offset
and the length
arguments index
characters outside the bounds of the bytes
array.public BitArray(int length)
BitArray
object so that it represents
an bit sequence which all bits is not set.length
- The length of this bitarray.public void clearBit(int position)
position
- the position of the bit to clear.public byte[] getBytes()
public void setBit(int position)
position
- the position of the bit to set.public boolean testBit(int position)
position
- the position of the bit to test.