[all packages]
[package java.util]
[class hierarchy]
[index]
java.lang.Object | +----java.util.BitSet
public final class BitSet implements Cloneable, java.io.Serializable
boolean value. The
bits of a BitSet are indexed by nonnegative integers.
Individual indexed bits can be examined, set, or cleared. One
BitSet may be used to modify the contents of another
BitSet through logical AND, logical inclusive OR, and
logical exclusive OR operations.
By default, all bits in the set initially have the value
false.
Every bit set has a current size, which is the number of bits currently in the bit set.

BitSet(int)
BitSet()

and(BitSet)
clear(int)
bitIndex in this BitSet
is changed to the
clone()
BitSet produces a new BitSet
that is equal to it.
equals(Object)
true if and
get(int)
hashCode()
or(BitSet)
set(int)
bitIndex in this BitSet
is changed to the
size()
BitSet to
toString()
xor(BitSet)

BitSetpublic BitSet();
false.public BitSet(int nbits);
0 through nbits-1.
All bits are initially false.

setpublic void set(int bitIndex);
bitIndex in this BitSet
is changed to the "set" (true) state. If
bitIndex is not smaller than the value that would be
returned by the size method, then
the size of this BitSet is increased to be larger
than bitIndex.
public void clear(int bitIndex);
bitIndex in this BitSet
is changed to the "clear" (false) state. If
bitIndex is not smaller than the value that would be
returned by the size method, then
the size of this BitSet is increased to be larger
than bitIndex.
public boolean get(int bitIndex);
true if the bit iwth the index bitIndex
is currently set in this BitSet; otherwise, the result
is false.
public void and(BitSet set);
true if and only if it both initially
had the value true and the corresponding bit in the
bit set argument also had the value true.
public void or(BitSet set);
true if and only if it either already had the
value true or the corresponding bit in the bit set
argument has the value true.
public void xor(BitSet set);
true if and only if one of the following
statements holds:
true, and the
corresponding bit in the argument has the value false.
false, and the
corresponding bit in the argument has the value true.
public int hashCode();
BitSet. The algorithm used to compute it may
be described as follows.
Suppose the bits in the BitSet were to be stored
in an array of long integers called, say,
bits, in such a manner that bit k is
set in the BitSet (for nonnegative values of
k) if and only if the expression
((k>>6) < bits.length) && ((bits[k>>6] & (1L << (bit & 0x3F))) != 0)is true. Then the following definition of the
hashCode
method would be a correct implementation of the actual algorithm:
public synchronized int hashCode() {
long h = 1234;
for (int i = bits.length; --i >= 0; ) {
h ^= bits[i] * (i + 1);
}
return (int)((h >> 32) ^ h);
}
Note that the hash code values change if the set of bits is altered.
Overrides the hashCode method of Object.
public int size();
BitSet to represent bit values.
The maximum element in the set is the size - 1st element.
public boolean equals(Object obj);
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 as this bit
set. That is, for every nonnegative int index k,
((BitSet)obj).get(k) == this.get(k)must be true. The current sizes of the two bit sets are not compared.
Overrides the equals method of Object.
true if the objects are the same;
false otherwise.public Object clone();
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 the clone method of Object.
public String toString();
BitSet contains a bit in the set
state, the decimal representation of that index is included in
the result. Such indeces aer listed in order from lowest to
highest, separated by ",$nbsp;" (a comma and a space) and
surrounded by braces, resulting in the usual mathematical
notation for a set of integers.
Overrides the toString method of Object.
Example:
BitSet drPepper = new BitSet();Now
drPepper.toString() returns "{}".
drPepper.set(2);Now
drPepper.toString() returns "{2}".
drPepper.set(4); drPepper.set(10);Now
drPepper.toString() returns "{2, 4, 10}".
[all packages]
[package java.util]
[class hierarchy]
[index]