@Override public Entry<K, V> lastEntry() { return unmodifiableOrNull(delegate.lastEntry()); }
@Override public Entry<K, V> lastEntry() { return delegate.lastEntry(); }
@Override public Entry<K, V> lastEntry() { synchronized (mutex) { return nullableSynchronizedEntry(delegate().lastEntry(), mutex); } }
/** * A sensible definition of {@link #lowerEntry} in terms of the {@code lastEntry()} of {@link * #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code * lowerEntry} to forward to this implementation. */ protected Entry<K, V> standardLowerEntry(K key) { return headMap(key, false).lastEntry(); }
/** * A sensible definition of {@link #floorEntry} in terms of the {@code lastEntry()} of {@link * #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code * floorEntry} to forward to this implementation. */ protected Entry<K, V> standardFloorEntry(K key) { return headMap(key, true).lastEntry(); }
@Override public Entry<K, V> firstEntry() { return forward().lastEntry(); }
@Override public Entry<K, V> lastEntry() { return delegate().lastEntry(); }
@Override public Range<C> span() { Entry<Cut<C>, Range<C>> firstEntry = rangesByLowerBound.firstEntry(); Entry<Cut<C>, Range<C>> lastEntry = rangesByLowerBound.lastEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return Range.create(firstEntry.getValue().lowerBound, lastEntry.getValue().upperBound); }
public Range getSpan() { if (lowIndexedRanges.isEmpty()) { throw new IllegalStateException("Can not get span if no ranges exist"); } return lowIndexedRanges.firstEntry().getValue().span(lowIndexedRanges.lastEntry().getValue()); }
@Override public Range<C> span() { Entry<Cut<C>, Range<C>> firstEntry = rangesByLowerBound.firstEntry(); Entry<Cut<C>, Range<C>> lastEntry = rangesByLowerBound.lastEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return Range.create(firstEntry.getValue().lowerBound, lastEntry.getValue().upperBound); }
@Override public @Nullable Entry<K, V> floorEntry(K key) { return headMap(key, true).lastEntry(); }
@CollectionSize.Require(ZERO) public void testEmptyMapLast() { assertNull(navigableMap.lastEntry()); }
@CollectionSize.Require(SEVERAL) public void testLast() { assertEquals(c, navigableMap.lastEntry()); }
@Override public Entry<K, V2> lastEntry() { return transformEntry(fromMap().lastEntry()); }
@CollectionSize.Require(ONE) public void testSingletonMapLast() { assertEquals(a, navigableMap.lastEntry()); }
@Override public @Nullable Entry<K, V> lowerEntry(K key) { return headMap(key, false).lastEntry(); }
@Override public Range<K> span() { Entry<Cut<K>, RangeMapEntry<K, V>> firstEntry = entriesByLowerBound.firstEntry(); Entry<Cut<K>, RangeMapEntry<K, V>> lastEntry = entriesByLowerBound.lastEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return Range.create( firstEntry.getValue().getKey().lowerBound, lastEntry.getValue().getKey().upperBound); }
@Override public Entry<K, V> lastEntry() { assertTrue(Thread.holdsLock(mutex)); return delegate().lastEntry(); }
public void testLastEntry() { create().lastEntry(); }
public void testStandardLastEntry() { NavigableMap<String, Integer> forwarding = new StandardLastEntryForwardingNavigableMap<>(new SafeTreeMap<String, Integer>()); assertNull(forwarding.lastEntry()); forwarding.put("b", 2); assertEquals(immutableEntry("b", 2), forwarding.lastEntry()); forwarding.put("c", 3); assertEquals(immutableEntry("c", 3), forwarding.lastEntry()); forwarding.put("a", 1); assertEquals(immutableEntry("c", 3), forwarding.lastEntry()); forwarding.remove("c"); assertEquals(immutableEntry("b", 2), forwarding.lastEntry()); }