com.ibm.wala.util.intset
Class BitSet<T>

java.lang.Object
  extended by com.ibm.wala.util.intset.BitSet<T>

public final class BitSet<T>
extends java.lang.Object

A bit set is a set of elements, each of which corresponds to a unique integer from [0,MAX].


Constructor Summary
BitSet(BitSet<T> B)
           
BitSet(OrdinalSetMapping<T> map)
          Constructor: create an empty set corresponding to a given mapping
 
Method Summary
 void add(T o)
          Add an object to this bit set.
 void addAll(BitSet<?> B)
          Add all elements in bitset B to this bit set
 void addAll(BitVector B)
          Add all bits in BitVector B to this bit set
 void clear(T o)
          Remove an object from this bit set.
 void clearAll()
          Set all the bits to 0.
 boolean contains(T o)
          Does this set contain a certain object?
 void copyBits(BitSet<T> other)
          Method copy.
 void difference(BitSet<T> other)
          Perform the difference of two bit sets
 void intersect(BitSet<?> other)
          Perform intersection of two bitsets
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Not very efficient.
 int length()
           
 boolean sameBits(BitSet<?> other)
          Does this object hold the same bits as other?
 void setAll()
          Set all the bits to 1.
 int size()
          Method size.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitSet

public BitSet(OrdinalSetMapping<T> map)
Constructor: create an empty set corresponding to a given mapping

Throws:
java.lang.IllegalArgumentException - if map is null

BitSet

public BitSet(BitSet<T> B)
       throws java.lang.NullPointerException
Throws:
java.lang.NullPointerException
Method Detail

addAll

public void addAll(BitSet<?> B)
Add all elements in bitset B to this bit set

Throws:
java.lang.IllegalArgumentException - if B is null

addAll

public void addAll(BitVector B)
Add all bits in BitVector B to this bit set


add

public void add(T o)
Add an object to this bit set.


clear

public void clear(T o)
Remove an object from this bit set.

Parameters:
o - the object to remove

contains

public boolean contains(T o)
Does this set contain a certain object?


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a String representation

copyBits

public void copyBits(BitSet<T> other)
Method copy. Copies the bits in the bit vector, but only assigns the object map. No need to create a new object/bit bijection object.

Throws:
java.lang.IllegalArgumentException - if other is null

sameBits

public boolean sameBits(BitSet<?> other)
Does this object hold the same bits as other?

Throws:
java.lang.IllegalArgumentException - if other is null

iterator

public java.util.Iterator iterator()
Not very efficient.


size

public int size()
Method size.

Returns:
int

length

public int length()

clearAll

public void clearAll()
Set all the bits to 0.


setAll

public void setAll()
Set all the bits to 1.


intersect

public void intersect(BitSet<?> other)
Perform intersection of two bitsets

Parameters:
other - the other bitset in the operation
Throws:
java.lang.IllegalArgumentException - if other is null

difference

public void difference(BitSet<T> other)
Perform the difference of two bit sets

Parameters:
other -
Throws:
java.lang.IllegalArgumentException - if other is null

isEmpty

public boolean isEmpty()