BitSet.nextSetBit

Returns the index of the first bit that is set to {@code true} that occurs on or after the specified starting index. If no such bit exists then {@code -1} is returned.

<p>To iterate over the {@code true} bits in a {@code BitSet}, use the following loop:

<pre> {@code for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) { // operate on index i here if (i == Integer.MAX_VALUE) { break; // or (i+1) would overflow } }}</pre>

@param fromIndex the index to start checking from (inclusive) @return the index of the next set bit, or {@code -1} if there is no such bit @throws IndexOutOfBoundsException if the specified index is negative

class BitSet
size_t
nextSetBit
(
size_t fromIndex
)

Meta