java.lang.Object
org.klomp.snark.BitField
org.klomp.snark.CompleteBitField
A full bitfield, immutable, to save memory and time. Overrides all methods except size().
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionCompleteBitField(int size) Creates a new CompleteBitField that representssizeset bits.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclear(int bit) Mark the given bit false.booleancomplete()Returns true if all bits are set.intcount()Returns the number of set bits.booleanCompares this BitField to another object for equality.booleanget(int bit) Returns true if the bit is set or false if it is not.byte[]Returns the actual byte array used.inthashCode()Returns a hash code value for this BitField.voidset(int bit) Mark the given bit true.voidsetAll()Mark all bits true.toString()Compact range representation - "BitField(128)[0-4 9 22-30]" instead of enumerating every set bit.
Constructor Details
CompleteBitField
public CompleteBitField(int size) Creates a new CompleteBitField that representssizeset bits.- Parameters:
size- the number of bits in the bit field
Method Details
getFieldBytes
public byte[] getFieldBytes()Description copied from class:BitFieldReturns the actual byte array used. Changes to this array affect this BitField. Note that some bits at the end of the byte array are supposed to be always unset if they represent bits bigger then the size of the bitfield.Caller should synchronize on this and copy!
- Overrides:
getFieldBytesin classBitField- Returns:
- the internal byte array representing the bit field
set
clear
setAll
get
count
complete
hashCode
equals
toString