List of usage examples for java.util BitSet set
public void set(int bitIndex)
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);/* w w w. j a v a2 s .c o m*/ 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); // perform and operation between two bitsets bitset1.and(bitset2); // print the new bitset1 System.out.println(bitset1); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);//from w ww .j a v a 2 s . c o m 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); // perform andNot operation for the two bitsets bitset1.andNot(bitset2); // print the new bitset1 System.out.println(bitset1); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);// ww w. j a va2s . c o m bitset1.set(2); // assign values to bitset2 bitset2.set(2); bitset2.set(4); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); // clone bitset1 to bitset2 bitset2 = (BitSet) bitset1.clone(); // print new bitsets System.out.println(bitset1); System.out.println(bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);/*from w ww . j ava 2 s. c o m*/ bitset1.set(2); // assign values to bitset2 bitset2.set(2); bitset2.set(4); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); // flip from index 2 to index 5 of bitset1 and print it bitset1.flip(2, 5); System.out.println(bitset1); // flip from index 1 to index 5 of bitset2 and print it bitset2.flip(1, 5); System.out.println(bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);/*from w ww . ja va2 s . c om*/ 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); // set more values bitset1.set(1, 10); bitset2.set(5, 15); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);//from w w w.ja v a 2 s . c o m 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); // set more values bitset1.set(1, 10, false); bitset2.set(5, 15, true); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);// ww w. ja v a2s . co m 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); // set more values bitset1.set(1, false); bitset1.set(5, true); bitset2.set(1, false); bitset2.set(5, true); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);/*from w w w. jav a2 s. c o m*/ bitset1.set(2); // assign values to bitset2 bitset2.set(2); bitset2.set(4); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); // clear index 2 in bitset1 bitset1.clear(2); // clear index 4 in bitset2 bitset2.clear(4); // print new bitsets System.out.println(bitset1); System.out.println(bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);//from w w w.j av a 2s.c o m 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); // clear bitset1 bitset1.clear(); // clear bitset2 bitset2.clear(); // print new bitsets System.out.println(bitset1); System.out.println(bitset2); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0); bitset1.set(1);/*from w w w . j a v a2s . c om*/ bitset1.set(2); // assign values to bitset2 bitset2.set(2); bitset2.set(4); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); // check if bitset1 and 2 are empty System.out.println(bitset1.isEmpty()); System.out.println(bitset2.isEmpty()); // create a new empty bitset BitSet bitset3 = new BitSet(8); // check if bitset3 is empty System.out.println(bitset3.isEmpty()); }