List of usage examples for java.util BitSet BitSet
private BitSet(long[] words)
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);//from w w w . ja va 2 s. co m bitset1.set(1); 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);/*from www . ja v a 2 s.c o 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); // 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);//from w w w .j av a2 s.c o 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); // 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);//from www . j a va 2 s . 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); // 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);//from w w w . j av a 2 s . c om bitset1.set(1); 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);/*from w w w .java 2 s. com*/ 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); // 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);/* ww w . ja v a 2s . c o m*/ bitset1.set(1); 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()); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); // assign values to bitset1 bitset1.set(0);/* w ww.j a va 2s . co m*/ bitset1.set(1); bitset1.set(2); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println(Arrays.toString(bitset1.toLongArray())); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); // assign values to bitset1 bitset1.set(0);/*w w w . java 2 s.c om*/ bitset1.set(1); bitset1.set(2); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println(Arrays.toString(bitset1.toByteArray())); }
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);/*from www.j a va 2s . com*/ 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); // clear from index 2 to index 4 in bitset1 bitset1.clear(1, 4); // clear index 2 to index 8 in bitset2 bitset2.clear(2, 8); // print new bitsets System.out.println(bitset1); System.out.println(bitset2); }