⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitsettest.java

📁 kaffe Java 解释器语言,源码,Java的子集系统,开放源代码
💻 JAVA
字号:
/** * A test for java.util.BitSet * * Written by Edouard Parmelan <Edouard.Parmelan@France.NCR.COM> */import java.util.BitSet;public class BitSetTest {    private static void show(String name, BitSet b) {	    System.out.println(name + " = " + b + "\tlength " + b.length());    }    private static void equalTest(String name, BitSet a, BitSet b) {	System.out.println(name + " " + a.equals(b) + " == " + b.equals(a));    }    private static void hashCodeTest() {	BitSet a = new BitSet(64);	BitSet b = new BitSet(128);	a.set(1);	a.set(13);	b.set(1);	b.set(13);	show("a", a);	show("b", b);	equalTest("a == b", a, b);	System.out.println("hashCode()"		+ " a " + Integer.toString(a.hashCode(), 16)		+ " b " + Integer.toString(b.hashCode(), 16)		);	System.out.println();    }    public static void main(String args[]) {	hashCodeTest();	BitSet a = new BitSet(0);	BitSet b = new BitSet(0);	BitSet c = new BitSet(0);	BitSet d = null;	a.set(0);	a.set(1);	a.set(66);	show("a", a);	show("a.clone()", (BitSet)a.clone());	b.set(1);	b.set(2);	b.set(63);	show("b", b);	show("b.clone()", (BitSet)b.clone());	System.out.println();	show("c", c);	equalTest("a == b", a, b);	System.out.println();	d = (BitSet)a.clone();	d.or(b);	show("a or b", d);	show("clone()", (BitSet)d.clone());	c = new BitSet(0); c.or(d); show("{} or d", c);	equalTest("d == d.clone()", d, (BitSet)d.clone());	System.out.println();	d = (BitSet)a.clone();	d.and(b);	show("a and b", d);	show("clone()", (BitSet)d.clone());	c = new BitSet(0); c.or(d); show("{} or d", c);	equalTest("d == d.clone()", d, (BitSet)d.clone());	System.out.println();	d = (BitSet)a.clone();	d.xor(b);	show("a xor b", d);	show("clone()", (BitSet)d.clone());	c = new BitSet(0); c.or(d); show("{} or d", c);	equalTest("d == d.clone()", d, (BitSet)d.clone());	System.out.println();	d = (BitSet)a.clone();	d.andNot(b);	show("a andNot b = ", d);	show("clone()", (BitSet)d.clone());	c = new BitSet(0); c.or(d); show("{} or d", c);	equalTest("d == d.clone()", d, (BitSet)d.clone());	System.out.println();    }}/* Expected Output:a = {1, 13}	length 14b = {1, 13}	length 14a == b true == truehashCode() a 24d0 b 24d0a = {0, 1, 66}	length 67a.clone() = {0, 1, 66}	length 67b = {1, 2, 63}	length 64b.clone() = {1, 2, 63}	length 64c = {}	length 0a == b false == falsea or b = {0, 1, 2, 63, 66}	length 67clone() = {0, 1, 2, 63, 66}	length 67{} or d = {0, 1, 2, 63, 66}	length 67d == d.clone() true == truea and b = {1}	length 2clone() = {1}	length 2{} or d = {1}	length 2d == d.clone() true == truea xor b = {0, 2, 63, 66}	length 67clone() = {0, 2, 63, 66}	length 67{} or d = {0, 2, 63, 66}	length 67d == d.clone() true == truea andNot b =  = {0, 66}	length 67clone() = {0, 66}	length 67{} or d = {0, 66}	length 67d == d.clone() true == true*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -