Example usage for java.util BitSet previousClearBit

List of usage examples for java.util BitSet previousClearBit

Introduction

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

Prototype

public int previousClearBit(int fromIndex) 

Source Link

Document

Returns the index of the nearest bit that is set to false 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  .j  ava2  s  .co m*/
    bitset1.set(1);
    bitset1.set(2);

    // print the sets
    System.out.println("Bitset1:" + bitset1.previousClearBit(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   ww w . j a  va 2s  .  c  o  m

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

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

}