All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.BitSet

java.lang.Object
    |
    +----structure.BitSet

public class BitSet
extends Object
A simple class implementing a set of numbered bits.

See Also:
java.util.BitSet

Constructor Index

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

Method Index

 o add(int)
Adds a bit to the bitset, if not already there.
 o clear()
Remove all bits from the set.
 o clear(int)
Remove bits from set; set size to count.
 o clone()
Returns a copy of the set.
 o contains(int)
Determine if a bit is a member of the set.
 o difference(BitSet)
Computes the difference between this set and the other.
 o equals(Object)
Return true iff this set and o contain the same elements.
 o intersection(BitSet)
Return the intersection of this set and the other.
 o isEmpty()
Determine if a set is empty.
 o remove(int)
Remove bit i from the bitset.
 o subset(BitSet)
Returns true iff this set is a subset of the other.
 o toString()
Constructs string representing set.
 o union(BitSet)
Compute a new set that is the union of this set and other.

Constructors

 o BitSet
public BitSet()
Constructs an empty bitset.

Postcondition:
constructs an empty set of small integers

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

Postcondition:
constructs an empty set with count potential elements

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

Methods

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

Precondition:
i >= 0
Postcondition:
i is added to the set

Parameters:
i - The number of the bit to be added.
 o remove
public void remove(int i)
Remove bit i from the bitset.

Precondition:
i >= 0
Postcondition:
removes i from set if present

Parameters:
i - The index of the bit to be removed.
 o contains
public boolean contains(int i)
Determine if a bit is a member of the set.

Precondition:
i >= 0
Postcondition:
returns true iff i in set

Parameters:
i - The bit index of potential bit.
Returns:
True iff bit i is in the set.
 o clear
public void clear()
Remove all bits from the set.

Postcondition:
removes all values from set

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

Postcondition:
removes all values from set, sets set size to count

Parameters:
count - The new capacity of the newly empty set.
 o clone
public Object clone()
Returns a copy of the set.

Postcondition:
constructs a copy of the set

Returns:
A new BitSet with the same values as this.
Overrides:
clone in class Object
 o 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.

Precondition:
other is non-null
Postcondition:
constructs set w/elements from this and other

Parameters:
other - The set to be unioned with this.
Returns:
The union of the two sets.
 o 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.

Precondition:
other is not null
Postcondition:
constructs set w/elements in this and other

Parameters:
other - The other set to be intersected with this.
 o 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.

Precondition:
other is not null
Postcondition:
constructs set w/elements from this but not other

Parameters:
other - The difference between this set and other.
 o 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.

Precondition:
other is not null
Postcondition:
returns true iff elements of this are all in other

Parameters:
other - The potential superset.
Returns:
The difference between this and other.
 o isEmpty
public boolean isEmpty()
Determine if a set is empty.

Postcondition:
returns true iff this set is empty

Returns:
True iff this set is empty.
 o equals
public boolean equals(Object o)
Return true iff this set and o contain the same elements.

Precondition:
o is not null
Postcondition:
returns true iff this and o have same elements

Parameters:
o - Another non-null bitset.
Returns:
True iff this set has the same elements as o.
Overrides:
equals in class Object
 o toString
public String toString()
Constructs string representing set.

Postcondition:
returns string representation of set

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index