Long2DoubleSortedArrayMap(SortedKeyIndex ks, double[] vs) { Preconditions.checkArgument(vs.length >= ks.getUpperBound(), "index and value sizes mismatched"); keys = ks; values = vs; }
@Override public Entry last() { if (isEmpty()) { throw new NoSuchElementException(); } return entry(keys.getUpperBound() - 1); }
@Override public long lastLong() { if (keys.size() > 0) { return keys.getKey(keys.getUpperBound() - 1); } else { throw new NoSuchElementException(); } }
@Override public Long2DoubleSortedMap tailMap(long l) { int startIdx = keys.findLowerBound(l); // include 'l' return createSubMap(startIdx, keys.getUpperBound()); }
public EntryIter() { iter = IntIterators.fromTo(keys.getLowerBound(), keys.getUpperBound()); }
@Override public LongSortedSet tailSet(long key) { int start = keys.findLowerBound(key); int end = keys.getUpperBound(); return new LongSortedArraySet(keys.subIndex(start, end)); }
Long2DoubleSortedArrayMap(SortedKeyIndex ks, double[] vs) { Preconditions.checkArgument(vs.length >= ks.getUpperBound(), "index and value sizes mismatched"); keys = ks; values = vs; }
@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 Entry last() { if (isEmpty()) { throw new NoSuchElementException(); } return entry(keys.getUpperBound() - 1); }
@Override public long lastLong() { if (keys.size() > 0) { return keys.getKey(keys.getUpperBound() - 1); } else { throw new NoSuchElementException(); } }
@Override public Long2DoubleSortedMap tailMap(long l) { int startIdx = keys.findLowerBound(l); // include 'l' return createSubMap(startIdx, keys.getUpperBound()); }
public EntryIter() { iter = IntIterators.fromTo(keys.getLowerBound(), keys.getUpperBound()); }
@Override public LongSortedSet tailSet(long key) { int start = keys.findLowerBound(key); int end = keys.getUpperBound(); return new LongSortedArraySet(keys.subIndex(start, end)); }