Package org.klomp.snark
Class CompleteBitField
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().
- Since:
- 0.9.71
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCompleteBitField(int size) Creates a new BitField that representssizeset bits. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear(int bit) Sets the given bit to false.booleancomplete()Return true if all bits are set.intcount()Return the number of set bits.booleanbooleanget(int bit) Return true if the bit is set or false if it is not.byte[]This returns the actual byte array used.inthashCode()voidset(int bit) Sets the given bit to true.voidsetAll()Sets all bits to true.toString()
-
Constructor Details
-
CompleteBitField
public CompleteBitField(int size) Creates a new BitField that representssizeset bits.
-
-
Method Details
-
getFieldBytes
public byte[] getFieldBytes()Description copied from class:BitFieldThis returns 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 synch on this and copy!- Overrides:
getFieldBytesin classBitField
-
set
public void set(int bit) Description copied from class:BitFieldSets the given bit to true. -
clear
public void clear(int bit) Description copied from class:BitFieldSets the given bit to false. -
setAll
public void setAll()Description copied from class:BitFieldSets all bits to true. -
get
public boolean get(int bit) Description copied from class:BitFieldReturn true if the bit is set or false if it is not. -
count
public int count()Description copied from class:BitFieldReturn the number of set bits. -
complete
public boolean complete()Description copied from class:BitFieldReturn true if all bits are set. -
hashCode
public int hashCode() -
equals
-
toString
-