BitSet.PreviousSetBit(Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the index of the nearest bit that is set to true
that occurs on or before the specified starting index.
[Android.Runtime.Register("previousSetBit", "(I)I", "GetPreviousSetBit_IHandler")]
public virtual int PreviousSetBit (int fromIndex);
[<Android.Runtime.Register("previousSetBit", "(I)I", "GetPreviousSetBit_IHandler")>]
abstract member PreviousSetBit : int -> int
override this.PreviousSetBit : int -> int
Parameters
- fromIndex
- Int32
the index to start checking from (inclusive)
Returns
the index of the previous set bit, or -1
if there
is no such bit
- Attributes
Exceptions
if index
.
Remarks
Returns the index of the nearest bit that is set to true
that occurs on or before the specified starting index. If no such bit exists, or if -1
is given as the starting index, then -1
is returned.
To iterate over the true
bits in a BitSet
, use the following loop:
{@code
for (int i = bs.length(); (i = bs.previousSetBit(i-1)) >= 0; ) {
// operate on index i here
}}
Added in 1.7.
Java documentation for java.util.BitSet.previousSetBit(.*int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.