MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / binarySearch

Method binarySearch

src/main/java/wycc/util/Trie.java:318–335  ·  view source on GitHub ↗
(final Trie[] children, final int nchildren, final String key)

Source from the content-addressed store, hash-verified

316 }
317
318 private static final int binarySearch(final Trie[] children, final int nchildren, final String key) {
319 int low = 0;
320 int high = nchildren-1;
321
322 while (low <= high) {
323 int mid = (low + high) >> 1;
324 int c = children[mid].component.compareTo(key);
325
326 if (c < 0) {
327 low = mid + 1;
328 } else if (c > 0) {
329 high = mid - 1;
330 } else {
331 return mid;
332 }
333 }
334 return -(low + 1);
335 }
336
337 private static final class InternalIterator implements Iterator<String> {
338 private final Trie id;

Callers 1

appendMethod · 0.95

Calls 1

compareToMethod · 0.45

Tested by

no test coverage detected