public final class BitArray extends Object
Constructor and Description |
---|
BitArray(int size)
Creates a BitArray with fixed size of bits.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
array()
Returns the backing byte array of this bitset.
|
boolean |
get(int index)
Returns boolean value for a bit on specific position.
|
void |
set(int index,
Boolean value)
If the value given is TRUE, sets bit on given position.
|
byte |
toByte()
If possible, returns one byte as backing array.
|
void |
toByteBuf(io.netty.buffer.ByteBuf buffer)
Writes backing array to given ByteBuf, even if the backing array is
empty, to preserve the number of allocated bits.
|
String |
toString() |
static BitArray |
valueOf(byte info)
Returns new BitArray with given byte as backing.
|
static BitArray |
valueOf(byte[] bytes)
Returns a new BitArray with given byte array as backing.
|
static BitArray |
valueOf(io.netty.buffer.ByteBuf buffer,
int size)
Returns a new BitArray created from bytes from given ByteBuf.
|
public BitArray(int size)
size
- Number of bits relevant for this BitArray. Needs to be greater than 0.public static BitArray valueOf(io.netty.buffer.ByteBuf buffer, int size)
buffer
- ByteBuf, whose readerIndex will be moved by
minimum number of bytes required for the bit size.size
- Number of bits to be allocated in BitArraypublic static BitArray valueOf(byte[] bytes)
bytes
- byte arraypublic static BitArray valueOf(byte info)
info
- unsigned bytepublic void set(int index, Boolean value)
index
- position of bit that will be setvalue
- Booleanpublic boolean get(int index)
index
- position of bitpublic byte[] array()
public byte toByte()
public void toByteBuf(io.netty.buffer.ByteBuf buffer)
buffer
- ByteBufCopyright © 2019 OpenDaylight. All rights reserved.