Package java.util |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public final class java.util.BitSet extends java.lang.Object implements java.lang.Cloneable { // Constructors public BitSet(); public BitSet(int nbits); // Methods public void and(BitSet set); public void clear(int bit); public Object clone(); public boolean equals(Object obj); public boolean get(int bit); public int hashCode(); public void or(BitSet set); public void set(int bit); public int size(); public String toString(); public void xor(BitSet set); }
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 inded by nonnegative integers. Individual bits can be examined, set, or cleared.
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.
public BitSet()Creates a new bit set. All bits are initially false.
public BitSet(int nbits)Creates a bit set whose initial size is the specified number of bits. All bits are initially false.
Parameter Description nbits the initial size of the bit set.
public void and(BitSet set)Performs a logical and of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value 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.
Parameter Description set a bit set
public void clear(int bit)Sets the bit specified by the index to false.
Parameter Description bit the index of the bit to be cleared
public Object clone()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 .
Return Value:
Returns a clone of this bit set.
Overrides:
clone in class Object .
public boolean equals(Object obj)The result is 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. The current sizes of the two bit sets are not compared.
Return Value:
Returns true if the objects are the same; false otherwise.
Parameter Description obj the object to compare with Overrides:
equals in class Object .
public boolean get(int bit)Return Value:
Returns the value of the bit with the specified index.
Parameter Description bit the bit index
public int hashCode()Return Value:
Returns a hash code value for this bit set.
Overrides:
hashCode in class Object .
public void or(BitSet set)Performs a logical or of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value 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.
Parameter Description set a bit set
public void set(int bit)Sets the bit specified by the index to true.
Parameter Description bit a bit index.
public int size()Return Value:
Returns the number of bits currently in this bit set.
public String toString()Return Value:
Returns a string representation of this bit set.
Overrides:
toString in class Object .
public void xor(BitSet set)Performs a logical xor of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:
- The bit initially has the value true, and the corresponding bit in the argument has the value false.
- The bit initially has the value false, and the corresponding bit in the argument has the value true.
Parameter Description set a bit set