BitSet.previousSetBit

Returns the index of the nearest bit that is set to {@code true} that occurs on or before the specified starting index. If no such bit exists, or if {@code -1} is given as the starting index, 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.length(); (i = bs.previousSetBit(i-1)) >= 0; ) { // operate on index i here }}</pre>

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

class BitSet
size_t
previousSetBit
(
size_t fromIndex
)

Meta