structure
Class BitSet

java.lang.Object
  extended by structure.BitSet

public class BitSet
extends Object

A simple class implementing a set of numbered bits.


Constructor Summary
BitSet()
          Constructs an empty bitset.
BitSet(int count)
          Constructs an empty bitset with potential to hold values between 0..count-1.
 
Method Summary
 void add(int i)
          Adds a bit to the bitset, if not already there.
 void clear()
          Remove all bits from the set.
 void clear(int count)
          Remove bits from set; set size to count.
 Object clone()
          Returns a copy of the set.
 boolean contains(int i)
          Determine if a bit is a member of the set.
 Object difference(BitSet other)
          Computes the difference between this set and the other.
 boolean equals(Object o)
          Return true iff this set and o contain the same elements.
 Object intersection(BitSet other)
          Return the intersection of this set and the other.
 boolean isEmpty()
          Determine if a set is empty.
 void remove(int i)
          Remove bit i from the bitset.
 boolean subset(BitSet other)
          Returns true iff this set is a subset of the other.
 String toString()
          Constructs string representing set.
 Object union(BitSet other)
          Compute a new set that is the union of this set and other.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitSet

public BitSet()
Constructs an empty bitset.


BitSet

public BitSet(int count)
Constructs an empty bitset with potential to hold values between 0..count-1.

Parameters:
count - The number of distinct values possibly in set.
Method Detail

add

public void add(int i)
Adds a bit to the bitset, if not already there. Set is potentially extended.

Parameters:
i - The number of the bit to be added.

remove

public void remove(int i)
Remove bit i from the bitset.

Parameters:
i - The index of the bit to be removed.

contains

public boolean contains(int i)
Determine if a bit is a member of the set.

Parameters:
i - The bit index of potential bit.
Returns:
True iff bit i is in the set.

clear

public void clear()
Remove all bits from the set.


clear

public void clear(int count)
Remove bits from set; set size to count.

Parameters:
count - The new capacity of the newly empty set.

clone

public Object clone()
Returns a copy of the set.

Overrides:
clone in class Object
Returns:
A new BitSet with the same values as this.

union

public Object union(BitSet other)
Compute a new set that is the union of this set and other. Elements of the new set appear in at least one of the two sets.

Parameters:
other - The set to be unioned with this.
Returns:
The union of the two sets.

intersection

public Object intersection(BitSet other)
Return the intersection of this set and the other. A bit is in the result if it is in this set and other.

Parameters:
other - The other set to be intersected with this.

difference

public Object difference(BitSet other)
Computes the difference between this set and the other. An element is in the difference if it is in this, but not in other.

Parameters:
other - The difference between this set and other.

subset

public boolean subset(BitSet other)
Returns true iff this set is a subset of the other. A set is a subset of another if its elements are elements of the other.

Parameters:
other - The potential superset.
Returns:
The difference between this and other.

isEmpty

public boolean isEmpty()
Determine if a set is empty.

Returns:
True iff this set is empty.

equals

public boolean equals(Object o)
Return true iff this set and o contain the same elements.

Overrides:
equals in class Object
Parameters:
o - Another non-null bitset.
Returns:
True iff this set has the same elements as o.

toString

public String toString()
Constructs string representing set.

Overrides:
toString in class Object
Returns:
String representing bitset.