jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
Simple bitfield interface for efficient bit storage access in O(1). More...
Classes | |
class | Factory |
Simple Bitfield factory for returning the efficient implementation. More... | |
Public Member Functions | |
int | size () |
Returns the storage size in bit units, e.g. More... | |
void | clearField (final boolean bit) |
Set all bits of this bitfield to the given value bit . More... | |
int | get32 (final int lowBitnum, final int length) throws IndexOutOfBoundsException |
Returns length bits from this storage, starting with the lowest bit from the storage position lowBitnum . More... | |
void | put32 (final int lowBitnum, final int length, final int data) throws IndexOutOfBoundsException |
Puts length bits of given data into this storage, starting w/ the lowest bit to the storage position lowBitnum . More... | |
int | copy32 (final int srcLowBitnum, final int dstLowBitnum, final int length) throws IndexOutOfBoundsException |
Copies length bits at position srcLowBitnum to position dstLowBitnum and returning the bits. More... | |
boolean | get (final int bitnum) throws IndexOutOfBoundsException |
Return true if the bit at position bitnum is set, otherwise false . More... | |
boolean | put (final int bitnum, final boolean bit) throws IndexOutOfBoundsException |
Set or clear the bit at position bitnum according to bit and return the previous value. More... | |
void | set (final int bitnum) throws IndexOutOfBoundsException |
Set the bit at position bitnum according to bit . More... | |
void | clear (final int bitnum) throws IndexOutOfBoundsException |
Clear the bit at position bitnum according to bit . More... | |
boolean | copy (final int srcBitnum, final int dstBitnum) throws IndexOutOfBoundsException |
Copies the bit at position srcBitnum to position dstBitnum and returning true if the bit is set, otherwise false . More... | |
int | bitCount () |
Returns the number of one bits within this bitfield. More... | |
Simple bitfield interface for efficient bit storage access in O(1).
Definition at line 34 of file Bitfield.java.
int org.jau.util.Bitfield.bitCount | ( | ) |
Returns the number of one bits within this bitfield.
Utilizes {#link Bitfield.Util#bitCount(int)
}.
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
void org.jau.util.Bitfield.clear | ( | final int | bitnum | ) | throws IndexOutOfBoundsException |
Clear the bit at position bitnum
according to bit
.
bitnum | bit number, restricted to [0..size() -1]. |
IndexOutOfBoundsException | if bitnum is out of bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
void org.jau.util.Bitfield.clearField | ( | final boolean | bit | ) |
Set all bits of this bitfield to the given value bit
.
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
boolean org.jau.util.Bitfield.copy | ( | final int | srcBitnum, |
final int | dstBitnum | ||
) | throws IndexOutOfBoundsException |
Copies the bit at position 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 bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
int org.jau.util.Bitfield.copy32 | ( | final int | srcLowBitnum, |
final int | dstLowBitnum, | ||
final int | length | ||
) | throws IndexOutOfBoundsException |
Copies 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 bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
boolean org.jau.util.Bitfield.get | ( | final int | bitnum | ) | throws IndexOutOfBoundsException |
Return 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 bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
int org.jau.util.Bitfield.get32 | ( | final int | lowBitnum, |
final int | length | ||
) | throws IndexOutOfBoundsException |
Returns 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 bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
boolean org.jau.util.Bitfield.put | ( | final int | bitnum, |
final boolean | bit | ||
) | throws IndexOutOfBoundsException |
Set or clear the bit at position bitnum
according to bit
and return the previous value.
bitnum | bit number, restricted to [0..size() -1]. |
IndexOutOfBoundsException | if bitnum is out of bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
void org.jau.util.Bitfield.put32 | ( | final int | lowBitnum, |
final int | length, | ||
final int | data | ||
) | throws IndexOutOfBoundsException |
Puts 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 storage |
IndexOutOfBoundsException | if rightBitnum is out of bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
void org.jau.util.Bitfield.set | ( | final int | bitnum | ) | throws IndexOutOfBoundsException |
Set the bit at position bitnum
according to bit
.
bitnum | bit number, restricted to [0..size() -1]. |
IndexOutOfBoundsException | if bitnum is out of bounds |
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.
int org.jau.util.Bitfield.size | ( | ) |
Returns the storage size in bit units, e.g.
32 bit for implementations using one int
field.
Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.