| 216 | // appendNegatedTable() returns the result of appending the negation of range |
| 217 | // table |table| to this CharClass. Does not mutate |table|. |
| 218 | CharClass appendNegatedTable(int[][] table) { |
| 219 | int nextLo = 0; // lo end of next class to add |
| 220 | for (int[] triple : table) { |
| 221 | int lo = triple[0], hi = triple[1], stride = triple[2]; |
| 222 | if (stride == 1) { |
| 223 | if (nextLo <= lo - 1) { |
| 224 | appendRange(nextLo, lo - 1); |
| 225 | } |
| 226 | nextLo = hi + 1; |
| 227 | continue; |
| 228 | } |
| 229 | for (int c = lo; c <= hi; c += stride) { |
| 230 | if (nextLo <= c - 1) { |
| 231 | appendRange(nextLo, c - 1); |
| 232 | } |
| 233 | nextLo = c + 1; |
| 234 | } |
| 235 | } |
| 236 | if (nextLo <= Unicode.MAX_RUNE) { |
| 237 | appendRange(nextLo, Unicode.MAX_RUNE); |
| 238 | } |
| 239 | return this; |
| 240 | } |
| 241 | |
| 242 | // appendTableWithSign() calls append{,Negated}Table depending on sign. |
| 243 | // Does not mutate |table|. |