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.


Constructor Index

 o Code(int)
Creates a Code of the specified size.

Method Index

 o concatenate(Code[])
Concatenates several Codes.
 o flip(int)
Flips a bit.
 o get(int)
Gets a bit.
 o getUnit(int)
For debugging only.
 o set(int, boolean)
Set a bit value.
 o size()
 o subCode(int, int)
Returns the subcode indexed by [a, b).

Constructors

 o 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

Methods

 o 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
 o get
 public boolean get(int bit)
Gets a bit.

Parameters:
bit - the index of the bit
 o flip
 public void flip(int bit)
Flips a bit.

Parameters:
bit - the index of the bit
 o subCode
 public Code subCode(int a,
                     int b)
Returns the subcode indexed by [a, b).

Throws: IndexOutOfBoundsException
on bad arguments
 o size
 public int size()
Returns:
my size
 o 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
 o getUnit
 public long getUnit(int i)
For debugging only.


All Packages  Class Hierarchy  This Package  Previous  Next  Index