public interface Bitfield
Modifier and Type | Interface and Description |
---|---|
static class |
Bitfield.Factory
Simple
Bitfield factory for returning the efficient implementation. |
static class |
Bitfield.Util
Bit operation utilities (static).
|
Modifier and Type | Field and Description |
---|---|
static int |
UNSIGNED_INT_MAX_VALUE
Maximum 32 bit Unsigned Integer Value:
0xffffffff == -1. |
Modifier and Type | Method and Description |
---|---|
int |
bitCount()
Returns the number of one bits within this bitfield.
|
void |
clear(int bitnum)
Clear the bit at position
bitnum according to bit . |
void |
clearField(boolean bit)
Set all bits of this bitfield to the given value
bit . |
boolean |
copy(int srcBitnum,
int dstBitnum)
Copies the bit at position
srcBitnum to position dstBitnum
and returning true if the bit is set, otherwise false . |
int |
copy32(int srcLowBitnum,
int dstLowBitnum,
int length)
Copies
length bits at position srcLowBitnum to position dstLowBitnum
and returning the bits. |
boolean |
get(int bitnum)
Return
true if the bit at position bitnum is set, otherwise false . |
int |
get32(int lowBitnum,
int length)
Returns
length bits from this storage,
starting with the lowest bit from the storage position lowBitnum . |
boolean |
put(int bitnum,
boolean bit)
Set or clear the bit at position
bitnum according to bit
and return the previous value. |
void |
put32(int lowBitnum,
int length,
int data)
Puts
length bits of given data into this storage,
starting w/ the lowest bit to the storage position lowBitnum . |
void |
set(int bitnum)
Set the bit at position
bitnum according to bit . |
int |
size()
Returns the storage size in bit units, e.g.
|
static final int UNSIGNED_INT_MAX_VALUE
0xffffffff
== -1.int size()
int
field.void clearField(boolean bit)
bit
.int get32(int lowBitnum, int length) throws IndexOutOfBoundsException
length
bits from this storage,
starting with the lowest bit from the storage position lowBitnum
.lowBitnum
- storage bit position of the lowest bit, restricted to [0..size()
-length
].length
- number of bits to read, constrained to [0..32].IndexOutOfBoundsException
- if rightBitnum
is out of boundsput32(int, int, int)
void put32(int lowBitnum, int length, int data) throws IndexOutOfBoundsException
length
bits of given data
into this storage,
starting w/ the lowest bit to the storage position lowBitnum
.lowBitnum
- storage bit position of the lowest bit, restricted to [0..size()
-length
].length
- number of bits to write, constrained to [0..32].data
- the actual bits to be put into this storageIndexOutOfBoundsException
- if rightBitnum
is out of boundsget32(int, int)
int copy32(int srcLowBitnum, int dstLowBitnum, int length) throws IndexOutOfBoundsException
length
bits at position srcLowBitnum
to position dstLowBitnum
and returning the bits.
Implementation shall operate as if invoking get32(int, int)
and then put32(int, int, int)
sequentially.
srcLowBitnum
- source bit number, restricted to [0..size()
-1].dstLowBitnum
- destination bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsget32(int, int)
,
put32(int, int, int)
boolean get(int bitnum) throws IndexOutOfBoundsException
true
if the bit at position bitnum
is set, otherwise false
.bitnum
- bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsboolean put(int bitnum, boolean bit) throws IndexOutOfBoundsException
bitnum
according to bit
and return the previous value.bitnum
- bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsvoid set(int bitnum) throws IndexOutOfBoundsException
bitnum
according to bit
.bitnum
- bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsvoid clear(int bitnum) throws IndexOutOfBoundsException
bitnum
according to bit
.bitnum
- bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsboolean copy(int srcBitnum, int dstBitnum) throws IndexOutOfBoundsException
srcBitnum
to position dstBitnum
and returning true
if the bit is set, otherwise false
.srcBitnum
- source bit number, restricted to [0..size()
-1].dstBitnum
- destination bit number, restricted to [0..size()
-1].IndexOutOfBoundsException
- if bitnum
is out of boundsint bitCount()
Utilizes {#link Bitfield.Util.bitCount(int)
}.