public class BitSet extends Object
implements Cloneable Serializable

This class implements a vector of bits that grows as needed. Each component of the bit set has a 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 of space currently in use by the bit set. Note that the size is related to the implementation of a bit set, so it may change with implementation. The length of a bit set relates to logical length of a bit set and is defined independently of implementation.

Unless otherwise noted, passing a null parameter to any of the methods in a BitSet will result in a NullPointerException.

A BitSet is not safe for multithreaded use without external synchronization.

Public Constructor Summary

Creates a new bit set.
BitSet(int nbits)
Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits-1.

Public Method Summary

and(BitSet set)
Performs a logical AND of this target bit set with the argument bit set.
andNot(BitSet set)
Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
Returns the number of bits set to true in this BitSet.
clear(int fromIndex, int toIndex)
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.
clear(int bitIndex)
Sets the bit specified by the index to false.
Sets all of the bits in this BitSet to false.