BitSet class Methods in Java Part -I

java.util.BitSet

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.

Some methods of ArrayDeque.


and(BitSet)This method performs a logical AND of this target bit set with the argument bit set.


andNot(BitSet)This method clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.


cardinality()This method returns the number of bits set to true in this BitSet.


clear()This method sets all of the bits in this BitSet to false.


clear(int)This method sets the bit specified by the index to false.


clone()This method of cloning this BitSet produces a new BitSet that is equal to it.



equals(Object)This method compares this object against the specified object.



flip(int)This method sets the bit at the specified index to the complement of its current value.



flip(int, int) This method sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the complement of its current value.



get(int)This method returns the value of the bit with the specified index.


get(int, int)This method returns a new BitSet composed of bits from this BitSetfrom fromIndex (inclusive) to toIndex (exclusive).



hashCode()The hash code depends only on which bits are set within this BitSet.



intersects(BitSet)This method returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.


isEmpty()This method returns true if this BitSet contains no bits that are set to true.



length()This method returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.


nextClearBit(int)This method returns the index of the first bit that is set to false that occurs on or after the specified starting index.




No comments:

Post a Comment