BitSet.NextSetBit(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 first bit that is set to true
that occurs on or after the specified starting index.
[Android.Runtime.Register("nextSetBit", "(I)I", "GetNextSetBit_IHandler")]
public virtual int NextSetBit (int fromIndex);
[<Android.Runtime.Register("nextSetBit", "(I)I", "GetNextSetBit_IHandler")>]
abstract member NextSetBit : int -> int
override this.NextSetBit : int -> int
Parameters
- fromIndex
- Int32
the index to start checking from (inclusive)
Returns
the index of the next set bit, or -1
if there
is no such bit
- Attributes
Exceptions
if index
.
Remarks
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.
To iterate over the true
bits in a BitSet
, use the following loop:
{@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
}
}}
Added in 1.4.
Java documentation for java.util.BitSet.nextSetBit(.*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.