All Packages Class Hierarchy This Package Previous Next Index
Class evolution.util.Code
java.lang.Object
|
+----evolution.util.Code
- public class Code
- extends Object
java.util.BitSet, as of JDK 1.1.5,
is not what we need (and does not work as documented).
E.g. new java.util.BitSet(3).size() == 64.
Portions of the code of Code are copied from java.util.BitSet,
with some modifications.
It has constant size, does not implement logical operations,
but can extract sub-Codes, concatenate Codes,
and has a method for setting a specified bit to a given value.
-
Code(int)
- Creates a Code of the specified size.
-
concatenate(Code[])
- Concatenates several
Codes.
-
flip(int)
- Flips a bit.
-
get(int)
- Gets a bit.
-
getUnit(int)
- For debugging only.
-
set(int, boolean)
- Set a bit value.
-
size()
-
-
subCode(int, int)
- Returns the subcode indexed by [a, b).
Code
public Code(int nbits)
- Creates a Code of the specified size. The bit values are not initialized!
- Parameters:
- nbits - the size of the set
set
public void set(int n,
boolean b)
- Set a bit value.
- Parameters:
- n - the index of the bit
- b - the value to set the bit to
get
public boolean get(int bit)
- Gets a bit.
- Parameters:
- bit - the index of the bit
flip
public void flip(int bit)
- Flips a bit.
- Parameters:
- bit - the index of the bit
subCode
public Code subCode(int a,
int b)
- Returns the subcode indexed by [a, b).
- Throws: IndexOutOfBoundsException
- on bad arguments
size
public int size()
- Returns:
- my size
concatenate
public static Code concatenate(Code c[]) throws BadSizeException
- Concatenates several
Codes.
- Throws: BadSizeException
- if the sum of the sizes of the codes
exceeds
Integer.MAX_VALUE
getUnit
public long getUnit(int i)
- For debugging only.
All Packages Class Hierarchy This Package Previous Next Index