@Override public Long2DoubleSortedArrayMap subMap(long from, long to) { int startIdx = keys.findLowerBound(from); // include 'from' int endIdx = keys.findLowerBound(to); // lower bound so we don't include 'to' return createSubMap(startIdx, endIdx); }
@Override public LongSortedSet subSet(long startKey, long endKey) { int start = keys.findLowerBound(startKey); int end = keys.findLowerBound(endKey); return new LongSortedArraySet(keys.subIndex(start, end)); }
@Override public Long2DoubleSortedMap tailMap(long l) { int startIdx = keys.findLowerBound(l); // include 'l' return createSubMap(startIdx, keys.getUpperBound()); }
@Override public Long2DoubleSortedMap headMap(long l) { int endIdx = keys.findLowerBound(l); // lower bound so we don't include 'l' return createSubMap(keys.getLowerBound(), endIdx); }
@Override public LongSortedSet headSet(long key) { int start = keys.getLowerBound(); int end = keys.findLowerBound(key); return new LongSortedArraySet(keys.subIndex(start, end)); }
@Override public LongSortedSet tailSet(long key) { int start = keys.findLowerBound(key); int end = keys.getUpperBound(); return new LongSortedArraySet(keys.subIndex(start, end)); }
@Test public void testSomeKeysLowerBound() { SortedKeyIndex keys = SortedKeyIndex.create(5, 6, 8); assertThat(keys.findLowerBound(0), equalTo(0)); assertThat(keys.findLowerBound(5), equalTo(0)); assertThat(keys.findLowerBound(6), equalTo(1)); assertThat(keys.findLowerBound(7), equalTo(2)); assertThat(keys.findLowerBound(8), equalTo(2)); assertThat(keys.findLowerBound(10), equalTo(3)); }
@Test public void testSingletonLowerBound() { SortedKeyIndex keys = SortedKeyIndex.create(5); assertThat(keys.findLowerBound(0), equalTo(0)); assertThat(keys.findLowerBound(5), equalTo(0)); assertThat(keys.findLowerBound(7), equalTo(1)); }
@Test public void testEmptyLowerBound() { SortedKeyIndex keys = SortedKeyIndex.empty(); assertThat(keys.findLowerBound(0), equalTo(0)); }
@Test public void testSubViewLowerBound() { SortedKeyIndex keys = SortedKeyIndex.create(0, 1, 2, 3, 4, 5, 6, 7); SortedKeyIndex subk = keys.subIndex(1, 5); assertThat(subk.getLowerBound(), equalTo(1)); assertThat(subk.getUpperBound(), equalTo(5)); assertThat(subk.tryGetIndex(1), equalTo(1)); assertThat(subk.tryGetIndex(4), equalTo(4)); assertThat(subk.tryGetIndex(5), lessThan(0)); assertThat(subk.tryGetIndex(6), lessThan(0)); assertThat(subk.tryGetIndex(0), lessThan(0)); assertThat(subk.findLowerBound(1L), equalTo(1)); assertThat(subk.findLowerBound(0L), equalTo(1)); assertThat(subk.findLowerBound(2L), equalTo(2)); assertThat(subk.findLowerBound(7L), equalTo(5)); assertThat(subk.findUpperBound(1), equalTo(2)); assertThat(subk.findUpperBound(5), equalTo(5)); assertThat(subk.findUpperBound(4), equalTo(5)); } }
@Override public Long2DoubleSortedArrayMap subMap(long from, long to) { int startIdx = keys.findLowerBound(from); // include 'from' int endIdx = keys.findLowerBound(to); // lower bound so we don't include 'to' return createSubMap(startIdx, endIdx); }
@Override public LongSortedSet subSet(long startKey, long endKey) { int start = keys.findLowerBound(startKey); int end = keys.findLowerBound(endKey); return new LongSortedArraySet(keys.subIndex(start, end)); }
@Override public Long2DoubleSortedMap headMap(long l) { int endIdx = keys.findLowerBound(l); // lower bound so we don't include 'l' return createSubMap(keys.getLowerBound(), endIdx); }
@Override public Long2DoubleSortedMap tailMap(long l) { int startIdx = keys.findLowerBound(l); // include 'l' return createSubMap(startIdx, keys.getUpperBound()); }
@Override public LongSortedSet tailSet(long key) { int start = keys.findLowerBound(key); int end = keys.getUpperBound(); return new LongSortedArraySet(keys.subIndex(start, end)); }
@Override public LongSortedSet headSet(long key) { int start = keys.getLowerBound(); int end = keys.findLowerBound(key); return new LongSortedArraySet(keys.subIndex(start, end)); }