Example usage for java.util BitSet BitSet

List of usage examples for java.util BitSet BitSet

Introduction

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

Prototype

public BitSet() 

Source Link

Document

Creates a new bit set.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);/*from  w  w w. j  a v a  2  s  .  c o m*/
    bites.set(1);
    bites.set(2);
    bites.set(3);
    System.out.println(bites);
}

From source file:Main.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);//from   w ww. j  a  v  a  2 s  .c  o m
    bites.set(1);
    bites.set(2);
    bites.set(3);
    System.out.println(bites);

    bites.andNot(bites);
    System.out.println(bites);

}

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);//from   w  w  w  . j a  v a2s . co  m
    bites.set(1);
    bites.set(2);
    bites.set(3);

    System.out.println(bites.size());
    System.out.println(bites.length());
}

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);/*w  w w .  j  a  v a  2 s  .  c o m*/
    bites.set(1);
    bites.set(2);
    bites.set(3);
    BitSet bitSetClone = (BitSet) bites.clone();
    System.out.println(bites);
    System.out.println(bitSetClone);
}

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 . jav  a2  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));

}

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = new BitSet();
    BitSet bitset2 = new BitSet();

    // assign values to bitset1
    bitset1.set(0);/*from   www .  j a va  2s . co  m*/
    bitset1.set(1);
    bitset1.set(2);

    // assign values to bitset2
    bitset2.set(2);
    bitset2.set(4);
    bitset2.set(6);

    // print the sets
    System.out.println("Bitset1:" + bitset1);
    System.out.println("Bitset2:" + bitset2);

}

From source file:MainClass.java

public static void main(String[] argv) {
    BitSet bs = new BitSet();
    bs.set(65);/* w  w w  .  j  ava2  s .  c  om*/
    System.out.println("Bit 65 is " + bs.get(65));
}

From source file:Main.java

public static void main(String[] args) {
    BitSet bs = new BitSet();
    bs.set(31);/*from   www. j  a  v  a2 s . c  om*/
    bs.set(15);
    bs.set(18);
    int[] intArray = bits2Ints(bs);

    for (int i = 0; i < intArray.length; i++)
        System.out.println(toBinary(intArray[i]));
}

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);/*from   w w w .  ja  v a2 s .c o m*/
    bites.set(1);
    bites.set(2);
    bites.set(3);
    System.out.println(bites);

    bites.and(bites);
    System.out.println(bites);

    bites.or(bites);
    System.out.println(bites);

    bites.xor(bites);
    System.out.println(bites);

    bites.andNot(bites);
    System.out.println(bites);

}

From source file:BitOps.java

public static void main(String args[]) {
    BitSet set = new BitSet();
    set.set(1);//  w w w  .  j av a 2s  .c o  m
    set.set(2);
    set.set(3);
    set.set(4);
    set.set(5);
    System.out.println(set);
    BitSet set2 = new BitSet();
    set2.set(1);
    set2.set(3);
    set2.set(5);
    set2.set(7);
    BitSet set3 = (BitSet) set.clone();
    set3.and(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.or(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.xor(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.andNot(set2);
    System.out.println(set3);
    set3.andNot(null);
}