BitSet class Methods in Java Part -II

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.


nextSetBit(int): This method returns the index of the first bit that is set to true that occurs on or after the specified starting index. If no such bit exists then -1 is returned.


or(BitSet): This method performs a logical OR of this bit set with the bit set argument.


previousClearBit(int): This method returns the index of the nearest bit that is set to false that occurs on or before the specified starting index.'


previousSetBit(int): This method returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.



set(int): This method sets the bit at the specified index to true.


set(int, boolean): This method sets the bit at the specified index to the specified value.


set(int, int): This method sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.


set(int, int, boolean): This method sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the specified value.



size(): This method returns the number of bits of space actually in use by this BitSet to represent bit values.



stream(): This method returns a stream of indices for which this BitSet contains a bit in the set state.


toByteArray(): This method returns a new byte array containing all the bits in this bit set.



toLongArray(): This method returns a new long array containing all the bits in this bit set.



toString(): This method returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result.



BitSet.valueOf(byte[]): This method returns a new bit set containing all the bits in the given byte array.



BitSet.valueOf(ByteBuffer): This method returns a new bit set containing all the bits in the given bytebuffer between its position and limit.



BitSet.valueOf(long[]): This method returns a new bit set containing all the bits in the given long array.


BitSet.valueOf(LongBuffer):  This method returns a new bit set containing all the bits in the given long buffer between its position and limit.



xor(BitSet): This method performs a logical XOR of this bit set with the bit set argument.





No comments:

Post a Comment