@Test public void lowIndex() { thrown.expect(IndexOutOfBoundsException.class); new CodePoints().at(-1); }
public int at(int index) { if (index < 0) throw new IndexOutOfBoundsException("illegal negative index: " + index); int min = 0; int max = ranges.size() - 1; while (min <= max) { int midpoint = min + ((max - min) / 2); CodePointRange current = ranges.get(midpoint); if (index >= current.previousCount && index < current.previousCount + current.size()) return current.low + index - current.previousCount; else if (index < current.previousCount) max = midpoint - 1; else min = midpoint + 1; } throw new IndexOutOfBoundsException(String.valueOf(index)); }
CodePoints { public int at(int index) { if (index < 0) throw new IndexOutOfBoundsException("illegal negative index: " + index); int min = 0; int max = ranges.size() - 1; while (min <= max) { int midpoint = min + ((max - min) / 2); CodePointRange current = ranges.get(midpoint); if (index >= current.previousCount && index < current.previousCount + current.size()) return current.low + index - current.previousCount; else if (index < current.previousCount) max = midpoint - 1; else min = midpoint + 1; } throw new IndexOutOfBoundsException(String.valueOf(index)); } }
CodePoints { public int at(int index) { if (index < 0) throw new IndexOutOfBoundsException("illegal negative index: " + index); int min = 0; int max = ranges.size() - 1; while (min <= max) { int midpoint = min + ((max - min) / 2); CodePointRange current = ranges.get(midpoint); if (index >= current.previousCount && index < current.previousCount + current.size()) return current.low + index - current.previousCount; else if (index < current.previousCount) max = midpoint - 1; else min = midpoint + 1; } throw new IndexOutOfBoundsException(String.valueOf(index)); } CodePoints(); }
CodePoints { public int at(int index) { if (index < 0) throw new IndexOutOfBoundsException("illegal negative index: " + index); int min = 0; int max = ranges.size() - 1; while (min <= max) { int midpoint = min + ((max - min) / 2); CodePointRange current = ranges.get(midpoint); if (index >= current.previousCount && index < current.previousCount + current.size()) return current.low + index - current.previousCount; else if (index < current.previousCount) max = midpoint - 1; else min = midpoint + 1; } throw new IndexOutOfBoundsException(String.valueOf(index)); } CodePoints(); int at(int index); int size(); boolean contains(int codePoint); static CodePoints forCharset(Charset c); }
CodePoints { public int at(int index) { if (index < 0) throw new IndexOutOfBoundsException("illegal negative index: " + index); int min = 0; int max = ranges.size() - 1; while (min <= max) { int midpoint = min + ((max - min) / 2); CodePointRange current = ranges.get(midpoint); if (index >= current.previousCount && index < current.previousCount + current.size()) return current.low + index - current.previousCount; else if (index < current.previousCount) max = midpoint - 1; else min = midpoint + 1; } throw new IndexOutOfBoundsException(String.valueOf(index)); } CodePoints(); int at(int index); int size(); boolean contains(int codePoint); static CodePoints forCharset(Charset c);  }