@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return filterEntries( unfiltered.subMap(fromKey, fromInclusive, toKey, toInclusive), entryPredicate); }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return Maps.unmodifiableNavigableMap( delegate.subMap(fromKey, fromInclusive, toKey, toInclusive)); }
@Override public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return delegate().subMap(fromKey, fromInclusive, toKey, toInclusive); }
@Override NavigableMap<K, V> createSubMap(SortedMap<K, V> sortedMap, K firstExclusive, K lastExclusive) { NavigableMap<K, V> map = (NavigableMap<K, V>) sortedMap; if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) { return map.headMap(lastInclusive, true); } else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) { return map.tailMap(firstExclusive, false); } else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) { return map.subMap(firstExclusive, false, lastExclusive, false); } else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) { return map.subMap(firstExclusive, false, lastInclusive, true); } else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) { return map.subMap(firstInclusive, true, lastInclusive, true); } else { return (NavigableMap<K, V>) super.createSubMap(map, firstExclusive, lastExclusive); } } }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return Maps.unmodifiableNavigableMap( delegate.subMap(fromKey, fromInclusive, toKey, toInclusive)); }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { synchronized (mutex) { return navigableMap(delegate().subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
@Override public NavigableMap<K, V2> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return transformEntries( fromMap().subMap(fromKey, fromInclusive, toKey, toInclusive), transformer); }
@Override public NavigableSet<K> subSet( K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) { return map().subMap(fromElement, fromInclusive, toElement, toInclusive).navigableKeySet(); }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return forward().subMap(toKey, toInclusive, fromKey, fromInclusive).descendingMap(); }
@Override public NavigableMap<K, V2> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return transformEntries( fromMap().subMap(fromKey, fromInclusive, toKey, toInclusive), transformer); }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { synchronized (mutex) { return navigableMap(delegate().subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
@Override public NavigableSet<K> subSet( K fromElement, boolean fromInclusive, K toElement, boolean toInclusive) { return map().subMap(fromElement, fromInclusive, toElement, toInclusive).navigableKeySet(); }
@Override public NavigableMap<K, V> subMap( K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { assertTrue(Thread.holdsLock(mutex)); return delegate().subMap(fromKey, fromInclusive, toKey, toInclusive); }
@Override public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return new SafeTreeMap<>( delegate.subMap(checkValid(fromKey), fromInclusive, checkValid(toKey), toInclusive)); }
@Override public SortedMap<K, V> subMap(K fromKey, K toKey) { return delegate().subMap(fromKey, true, toKey, false); }
@Override protected Map<String, Collection<Integer>> makeEmptyMap() { return createMultimap().asMap().subMap("e", "p"); }
public void testSubMap_K_K() { NavigableMap<String, Integer> map = create(); SortedMap<String, Integer> subMap = map.subMap("a", "b"); assertTrue(subMap instanceof SynchronizedSortedMap); assertSame(mutex, ((SynchronizedSortedMap<String, Integer>) subMap).mutex); }
@GwtIncompatible // NavigableMap public void testAsMapNavigableWritesThrough() { NavigableSet<String> strings = Sets.newTreeSet(); Collections.addAll(strings, "one", "two", "three"); NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION); assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map); assertEquals(Integer.valueOf(3), map.remove("two")); assertThat(strings).containsExactly("one", "three").inOrder(); assertEquals(mapEntry("three", 5), map.subMap("one", false, "zzz", true).pollLastEntry()); assertThat(strings).contains("one"); }
public void testSubMap_K_B_K_B() { NavigableMap<String, Integer> map = create(); NavigableMap<String, Integer> subMap = map.subMap("a", true, "b", false); assertTrue(subMap instanceof SynchronizedNavigableMap); assertSame(mutex, ((SynchronizedNavigableMap<String, Integer>) subMap).mutex); }
@Override protected Map<String, Collection<Integer>> makePopulatedMap() { TreeMultimap<String, Integer> multimap = createMultimap(); multimap.put("f", 1); multimap.put("f", 2); multimap.put("g", 3); multimap.put("h", 4); return multimap.asMap().subMap("e", "p"); }