Example usage for java.util BitSet previousSetBit

List of usage examples for java.util BitSet previousSetBit

Introduction

In this page you can find the example usage for java.util BitSet previousSetBit.

Prototype

public int previousSetBit(int fromIndex) 

Source Link

Document

Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.

Usage

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = new BitSet(8);

    // assign values to bitset1
    bitset1.set(0);//from w  w  w  .java2  s  . c  om
    bitset1.set(1);
    bitset1.set(2);

    // print the sets
    System.out.println("Bitset1:" + bitset1.previousSetBit(1));
}

From source file:Test.java

public static void main(String[] args) {
    BitSet bitSet = new BitSet();
    long[] array = { 1, 2, 3 };
    bitSet = BitSet.valueOf(array);
    System.out.println(bitSet);//from  w w  w.  j a  v a 2  s  .  com

    long[] tmp = bitSet.toLongArray();
    for (long number : tmp) {
        System.out.println(number);
    }

    System.out.println(bitSet.previousSetBit(1));
    System.out.println(bitSet.previousClearBit(66));

}