org.jikesrvm.util
Class BitVector

java.lang.Object
  extended by org.jikesrvm.util.BitVector
All Implemented Interfaces:
Serializable

public final class BitVector
extends Object
implements Serializable

Implements a bit vector.

See Also:
Serialized Form

Field Summary
private  int[] bits
           
private static int LOG_BITS_PER_UNIT
           
private static int LOW_MASK
           
private static int MASK
           
private  int nbits
           
(package private) static long serialVersionUID
          Support for serialization
 
Constructor Summary
BitVector(BitVector s)
          Creates a copy of a Bit String
BitVector(int nbits)
          Creates an empty string with the specified size.
 
Method Summary
 void and(BitVector set)
          Logically ANDs this bit set with the specified set of bits.
static BitVector and(BitVector b1, BitVector b2)
          Return a new bit string as the AND of two others.
 void clear(int bit)
          Clears a bit.
 void clearAll()
          Clears all bits.
 void copyBits(BitVector set)
          Copies the values of the bits in the specified set into this set.
 BitVector dup()
           
 boolean equals(Object obj)
          Compares this object against the specified object.
 boolean get(int bit)
          Gets a bit.
 int hashCode()
          Gets the hashcode.
 boolean intersectionEmpty(BitVector other)
          Check if the intersection of the two sets is empty
 boolean isZero()
           
 int length()
          Calculates and returns the set's size in bits.
 void not()
          Logically NOT this bit string
static BitVector not(BitVector s)
          Return the NOT of a bit string
 void or(BitVector set)
          Logically ORs this bit set with the specified set of bits.
static BitVector or(BitVector b1, BitVector b2)
          Return a new BitVector as the OR of two others
 int populationCount()
          How many bits are set?
 void set(int bit)
          Sets a bit.
 void setAll()
          Sets all bits.
private static int subscript(int bitIndex)
          Convert bitIndex to a subscript into the bits[] array.
 String toString()
          Converts the BitVector to a String.
 void xor(BitVector set)
          Logically XORs this bit set with the specified set of bits.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Support for serialization

See Also:
Constant Field Values

LOG_BITS_PER_UNIT

private static final int LOG_BITS_PER_UNIT
See Also:
Constant Field Values

MASK

private static final int MASK
See Also:
Constant Field Values

LOW_MASK

private static final int LOW_MASK
See Also:
Constant Field Values

bits

private final int[] bits

nbits

private final int nbits
Constructor Detail

BitVector

public BitVector(int nbits)
Creates an empty string with the specified size.

Parameters:
nbits - the size of the string

BitVector

public BitVector(BitVector s)
Creates a copy of a Bit String

Parameters:
s - the string to copy
Method Detail

subscript

private static int subscript(int bitIndex)
Convert bitIndex to a subscript into the bits[] array.


setAll

public void setAll()
Sets all bits.


set

public void set(int bit)
Sets a bit.

Parameters:
bit - the bit to be set

clearAll

public void clearAll()
Clears all bits.


clear

public void clear(int bit)
Clears a bit.

Parameters:
bit - the bit to be cleared

get

public boolean get(int bit)
Gets a bit.

Parameters:
bit - the bit to be gotten

not

public void not()
Logically NOT this bit string


not

public static BitVector not(BitVector s)
Return the NOT of a bit string


and

public void and(BitVector set)
Logically ANDs this bit set with the specified set of bits.

Parameters:
set - the bit set to be ANDed with

and

public static BitVector and(BitVector b1,
                            BitVector b2)
Return a new bit string as the AND of two others.


or

public void or(BitVector set)
Logically ORs this bit set with the specified set of bits.

Parameters:
set - the bit set to be ORed with

or

public static BitVector or(BitVector b1,
                           BitVector b2)
Return a new BitVector as the OR of two others


xor

public void xor(BitVector set)
Logically XORs this bit set with the specified set of bits.

Parameters:
set - the bit set to be XORed with

intersectionEmpty

public boolean intersectionEmpty(BitVector other)
Check if the intersection of the two sets is empty

Parameters:
other - the set to check intersection with

copyBits

public void copyBits(BitVector set)
Copies the values of the bits in the specified set into this set.

Parameters:
set - the bit set to copy the bits from

hashCode

public int hashCode()
Gets the hashcode.

Overrides:
hashCode in class Object

populationCount

public int populationCount()
How many bits are set?


length

public int length()
Calculates and returns the set's size in bits. The maximum element in the set is the size - 1st element.


equals

public boolean equals(Object obj)
Compares this object against the specified object.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.

isZero

public boolean isZero()

dup

public BitVector dup()

toString

public String toString()
Converts the BitVector to a String.

Overrides:
toString in class Object