package// // This software is now distributed according to // the Lesser Gnu Public License. Please see // http://www.gnu.org/copyleft/lesser.txt for // the details. // -- Happy Computing! // com.stevesoft.pat; public class Bits { char[] carray; Bits(char[] carray) { this.carray = carray; } public boolean get(int i) { return ((carray[i>>4]) & (1<<(i&15))) != 0; } public void set(int i,boolean b) { if(b) { carray[i>>4] |= (char) 1<<(i&15); } else { carray[i>>4] &= (char)~(1<<(i&15)); } } /* public static String n4(char c) { String s = Integer.toHexString(c); while(s.length()<4) s = "0"+s; return s; } static abstract class Tester { abstract boolean test(char c); } public static void main(String[] args) throws Exception { //pw_s.println(" static {"); FileWriter fw = new FileWriter("x.out"); fw.close(); test("upper",new Tester() { boolean test(char c) { return Character.isUpperCase(c); } }); test("lower",new Tester() { boolean test(char c) { return Character.isLowerCase(c); } }); test("title",new Tester() { boolean test(char c) { return Character.isLowerCase(c); } }); test("currency",new Tester() { boolean test(char c) { return Character.getType(c)==Character.CURRENCY_SYMBOL; } }); test("decimal_digit",new Tester() { boolean test(char c) { return Character.getType(c)==Character.DECIMAL_DIGIT_NUMBER; } }); test("math",new Tester() { boolean test(char c) { return Character.getType(c)==Character.MATH_SYMBOL; } }); test("letter",new Tester() { boolean test(char c) { return Character.isLetter(c); } }); test("white",new Tester() { boolean test(char c) { return Character.isWhitespace(c); } }); test("punct",new Tester() { boolean test(char c) { boolean r = false; switch(Character.getType(c)) { case Character.DASH_PUNCTUATION: case Character.START_PUNCTUATION: case Character.END_PUNCTUATION: case Character.CONNECTOR_PUNCTUATION: case Character.OTHER_PUNCTUATION: r = true; break; default: r = false; break; } return r; } }); //pw_s.println(" }"); fw = new FileWriter("x.out",true); fw.write(sw.toString()); fw.close(); } static StringWriter sw = new StringWriter(); static PrintWriter pw_s = new PrintWriter(sw,true); public static void test(String var,Tester t) throws Exception { char[] ca = new char[(66536 >> 4)+1]; Bits b = new Bits(ca); FileWriter fw = new FileWriter("x.out",true); PrintWriter pw = new PrintWriter(fw); //pw_s.println(" "+var+"_f();"); pw.println(" public static Bits "+var+";"); pw.println(" static void "+var+"_f() {"); pw.println(" char[] data = new char["+ca.length+"];"); pw.println(" "+var+" = new Bits(data);"); for(int i=0;i<66536;i++) { char c = (char)i; //b.set(i,Character.getType(c)==Character.CURRENCY_SYMBOL); b.set(i,t.test(c)); } for(int i=0;i