Package com.jogamp.common.util
Interface Bitfield
-
public interface BitfieldSimple bitfield interface for efficient bit storage access in O(1).- Since:
- 2.3.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classBitfield.FactorySimpleBitfieldfactory for returning the efficient implementation.static classBitfield.UtilBit operation utilities (static).
-
Field Summary
Fields Modifier and Type Field Description static intUNSIGNED_INT_MAX_VALUEMaximum 32 bit Unsigned Integer Value:0xffffffff== -1.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intbitCount()Returns the number of one bits within this bitfield.voidclear(int bitnum)Clear the bit at positionbitnumaccording tobit.voidclearField(boolean bit)Set all bits of this bitfield to the given valuebit.booleancopy(int srcBitnum, int dstBitnum)Copies the bit at positionsrcBitnumto positiondstBitnumand returningtrueif the bit is set, otherwisefalse.intcopy32(int srcLowBitnum, int dstLowBitnum, int length)Copieslengthbits at positionsrcLowBitnumto positiondstLowBitnumand returning the bits.booleanget(int bitnum)Returntrueif the bit at positionbitnumis set, otherwisefalse.intget32(int lowBitnum, int length)Returnslengthbits from this storage, starting with the lowest bit from the storage positionlowBitnum.booleanput(int bitnum, boolean bit)Set or clear the bit at positionbitnumaccording tobitand return the previous value.voidput32(int lowBitnum, int length, int data)Putslengthbits of givendatainto this storage, starting w/ the lowest bit to the storage positionlowBitnum.voidset(int bitnum)Set the bit at positionbitnumaccording tobit.intsize()Returns the storage size in bit units, e.g.
-
-
-
Field Detail
-
UNSIGNED_INT_MAX_VALUE
static final int UNSIGNED_INT_MAX_VALUE
Maximum 32 bit Unsigned Integer Value:0xffffffff== -1.- See Also:
- Constant Field Values
-
-
Method Detail
-
size
int size()
Returns the storage size in bit units, e.g. 32 bit for implementations using oneintfield.
-
clearField
void clearField(boolean bit)
Set all bits of this bitfield to the given valuebit.
-
get32
int get32(int lowBitnum, int length) throws IndexOutOfBoundsExceptionReturnslengthbits from this storage, starting with the lowest bit from the storage positionlowBitnum.- Parameters:
lowBitnum- storage bit position of the lowest bit, restricted to [0..size()-length].length- number of bits to read, constrained to [0..32].- Throws:
IndexOutOfBoundsException- ifrightBitnumis out of bounds- See Also:
put32(int, int, int)
-
put32
void put32(int lowBitnum, int length, int data) throws IndexOutOfBoundsExceptionPutslengthbits of givendatainto this storage, starting w/ the lowest bit to the storage positionlowBitnum.- Parameters:
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- Throws:
IndexOutOfBoundsException- ifrightBitnumis out of bounds- See Also:
get32(int, int)
-
copy32
int copy32(int srcLowBitnum, int dstLowBitnum, int length) throws IndexOutOfBoundsExceptionCopieslengthbits at positionsrcLowBitnumto positiondstLowBitnumand returning the bits.Implementation shall operate as if invoking
get32(int, int)and thenput32(int, int, int)sequentially.- Parameters:
srcLowBitnum- source bit number, restricted to [0..size()-1].dstLowBitnum- destination bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds- See Also:
get32(int, int),put32(int, int, int)
-
get
boolean get(int bitnum) throws IndexOutOfBoundsExceptionReturntrueif the bit at positionbitnumis set, otherwisefalse.- Parameters:
bitnum- bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds
-
put
boolean put(int bitnum, boolean bit) throws IndexOutOfBoundsExceptionSet or clear the bit at positionbitnumaccording tobitand return the previous value.- Parameters:
bitnum- bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds
-
set
void set(int bitnum) throws IndexOutOfBoundsException
Set the bit at positionbitnumaccording tobit.- Parameters:
bitnum- bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds
-
clear
void clear(int bitnum) throws IndexOutOfBoundsExceptionClear the bit at positionbitnumaccording tobit.- Parameters:
bitnum- bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds
-
copy
boolean copy(int srcBitnum, int dstBitnum) throws IndexOutOfBoundsExceptionCopies the bit at positionsrcBitnumto positiondstBitnumand returningtrueif the bit is set, otherwisefalse.- Parameters:
srcBitnum- source bit number, restricted to [0..size()-1].dstBitnum- destination bit number, restricted to [0..size()-1].- Throws:
IndexOutOfBoundsException- ifbitnumis out of bounds
-
bitCount
int bitCount()
Returns the number of one bits within this bitfield.Utilizes {#link
Bitfield.Util.bitCount(int)}.
-
-