|
© 1998-2002 McGraw-Hill | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--structure.BitSet
Implementation of a set of numbered bits. This class's interface
differs from the Set
, java.util.Bitset
,
and Set
interfaces, so care must be taken to
invoke the proper methods.
CharSet
,
java.util.BitSet
Field Summary | |
protected int |
allocated
The current number of integers allocated. |
protected int |
bitsPerInt
The number of bits contained in a single integer. |
protected int[] |
data
The array of integers that contains the set's bits |
protected int |
initialCapacity
The initial capacity of the set, by default. |
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. |
protected void |
extend(int bit)
Ensures that bit "bit" is within capacity of set. |
protected int |
indexOf(int b)
Determine the int index associated with a bit number. |
Object |
intersection(BitSet other)
Return the intersection of this set and the other. |
boolean |
isEmpty()
Determine if a set is empty. |
protected int |
offsetOf(int bit)
Return the bit index within the associated int of bit "bit" |
protected boolean |
probe(int bit)
Determines if bit is within capacity of set. |
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 |
|
Field Detail |
protected final int bitsPerInt
protected final int initialCapacity
protected int[] data
protected int allocated
Constructor Detail |
public BitSet()
public BitSet(int count)
count
- The number of distinct values possibly in set.Method Detail |
public void add(int i)
i
- The number of the bit to be added.public void remove(int i)
i
- The index of the bit to be removed.public boolean contains(int i)
i
- The bit index of potential bit.public void clear()
public void clear(int count)
count
- The new capacity of the newly empty set.public Object clone()
clone
in class Object
public Object union(BitSet other)
other
- The set to be unioned with this.public Object intersection(BitSet other)
other
- The other set to be intersected with this.public Object difference(BitSet other)
other
- The difference between this set and other.public boolean subset(BitSet other)
other
- The potential superset.public boolean isEmpty()
public boolean equals(Object o)
equals
in class Object
o
- Another non-null bitset.protected int indexOf(int b)
protected int offsetOf(int bit)
bit
- The index of the bit in set.protected void extend(int bit)
protected boolean probe(int bit)
bit
- The index of desired bit.public String toString()
toString
in class Object
|
© 1998-2002 McGraw-Hill | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |