Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 20 21 package JFlex; 22 23 24 32 final public class CharSetEnumerator { 33 34 private int index; 35 private int offset; 36 private long mask = 1; 37 38 private CharSet set; 39 40 public CharSetEnumerator(CharSet characters) { 41 set = characters; 42 43 while (index < set.bits.length && set.bits[index] == 0) 44 index++; 45 46 if (index >= set.bits.length) return; 47 48 while (offset <= CharSet.MOD && ((set.bits[index] & mask) == 0)) { 49 mask<<= 1; 50 offset++; 51 } 52 } 53 54 private void advance() { 55 do { 56 offset++; 57 mask<<= 1; 58 } while (offset <= CharSet.MOD && ((set.bits[index] & mask) == 0)); 59 60 if (offset > CharSet.MOD) { 61 do 62 index++; 63 while (index < set.bits.length && set.bits[index] == 0); 64 65 if (index >= set.bits.length) return; 66 67 offset = 0; 68 mask = 1; 69 70 while (offset <= CharSet.MOD && ((set.bits[index] & mask) == 0)) { 71 mask<<= 1; 72 offset++; 73 } 74 } 75 } 76 77 public boolean hasMoreElements() { 78 return index < set.bits.length; 79 } 80 81 public int nextElement() { 82 int x = (index << CharSet.BITS) + offset; 83 advance(); 84 return x; 85 } 86 87 } 88 89
| Popular Tags
|