soot.util
Class BitSet

java.lang.Object
  |
  +--soot.util.BitSet
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class BitSet
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A BitSet implementation based on Kaffe 1.0.6. The API is identical except for the addition of an efficient iterator (see also BitSetIterator). Also, unlike the Kaffe BitSet, this BitSet is unsynchronized (for efficiency purposes.

See Also:
Serialized Form

Constructor Summary
BitSet()
          Create a new BitSet.
BitSet(int nr)
          Create a new BitSet that can hold nr bits.
 
Method Summary
 void and(BitSet bitset)
          Performs a logical AND of this set and the argument bit set.
 void andNot(BitSet bitset)
          Performs a logical AND of this set and the COMPLEMENT of the argument bit set.
 void clear(int bit)
          Clear a bit in the set.
 java.lang.Object clone()
          Cloning this BitSet produces a new BitSet that is equal to it.
 boolean equals(java.lang.Object obj)
          Compares this object againts the specified object.
 boolean get(int bit)
          Returns the value of the bit in the set.
 int hashCode()
          Returns a hash code value for this bit set.
 BitSetIterator iterator()
          Returns an iterator over this BitSet.
 int length()
          Returns the index of the highest set bit in the set plus one.
 void or(BitSet bitset)
          Performs a logical OR of this set and the argument bit set.
 void set(int bit)
          Set a bit in the set.
 int size()
           
 java.lang.String toString()
          Returns a string representation of this bit set.
 void xor(BitSet bitset)
          Performs a logical EXCLUSIVE OR of this set and the argument bit set.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitSet

public BitSet()
Create a new BitSet.


BitSet

public BitSet(int nr)
Create a new BitSet that can hold nr bits. All bits are initialized to false.

Parameters:
nr - the inital size of the set.
Method Detail

iterator

public BitSetIterator iterator()
Returns an iterator over this BitSet.


set

public void set(int bit)
Set a bit in the set.

Parameters:
bit - the bit to set.

clear

public void clear(int bit)
Clear a bit in the set.

Parameters:
bit - the bit to clear.

get

public boolean get(int bit)
Returns the value of the bit in the set.

Parameters:
bit - the bit to check.
Returns:
the value of the bit.

length

public int length()
Returns the index of the highest set bit in the set plus one.

Returns:
the logical size of this set.
Since:
JDK1.2

size

public int size()
Returns:
the number of bits in the set.

equals

public boolean equals(java.lang.Object obj)
Compares this object againts the specified object. The result is true if and only if the argument is not null and is a BitSet object that has exactly the same set of bits set to true. The current sizes of the two sets are not compared.

Overrides:
equals in class java.lang.Object
Returns:
true if the objects are the same; false otherwise.

and

public void and(BitSet bitset)
Performs a logical AND of this set and the argument bit set. Result of the mathematical intersection of two sets.


andNot

public void andNot(BitSet bitset)
Performs a logical AND of this set and the COMPLEMENT of the argument bit set. Result of the mathematical substaction of two set.

Since:
JDK1.2

or

public void or(BitSet bitset)
Performs a logical OR of this set and the argument bit set. Result of the mathematical union of two sets.


xor

public void xor(BitSet bitset)
Performs a logical EXCLUSIVE OR of this set and the argument bit set.


hashCode

public int hashCode()
Returns a hash code value for this bit set.

Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
Cloning this BitSet produces a new BitSet that is equal to it. The clone of the bit set is another bit set that has exactly the same bits set to true as this bit set and the same current size.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result. Such indeces are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.

Overrides:
toString in class java.lang.Object