java.lang.Object eu.gressly.util.BitWorm
public class BitWorm
Array of Bits with a simple interface: get() and put(). A 1-Bit is represented by the boolean value "true" (0 is represented by "false").
Constructor Summary | |
---|---|
BitWorm()
Generate a bitworm with an initial capacity of 32 bits. |
|
BitWorm(int initialCapacity)
Generate a BitWorm with a initial Capacity of bits. |
Method Summary | |
---|---|
boolean |
get(int pos)
Read a boolean from a given position. |
static void |
main(java.lang.String[] args)
Test Method |
void |
set(int pos,
boolean value)
Set Bit[pos] to 1 (true) or 0 (false) If a "true (1)"-Bit is set in a position higher (or same) as the size(), the size of the Bitworm will be enlarged. |
int |
size()
Return the number of bits that have been assigned. |
boolean[] |
toBooleanArray()
Return the bitWorm in a boolean[] representation (0 = false ; 1 = true) |
java.lang.String |
toString()
Human readable form of this BitWorm. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BitWorm()
public BitWorm(int initialCapacity)
initialCapacity
- Method Detail |
---|
public boolean get(int pos)
pos
-
public void set(int pos, boolean value)
pos
- The first possible position is 0.value
- true for a 1 bit and false for a 0 bitpublic java.lang.String toString()
toString
in class java.lang.Object
public int size()
public boolean[] toBooleanArray()
public static void main(java.lang.String[] args)
args
- are not used