package com.google.common.collect; import com.google.common.collect.Maps; import java.util.Iterator; import java.util.Map; import java.util.NavigableMap; import java.util.NavigableSet; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedMap; import javax.annotation.CheckForNull; /* JADX INFO: Access modifiers changed from: package-private */ @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public abstract class AbstractNavigableMap extends Maps.IteratorBasedAbstractMap implements NavigableMap { abstract Iterator> descendingEntryIterator(); @Override // java.util.AbstractMap, java.util.Map @CheckForNull public abstract V get(@CheckForNull Object obj); @Override // java.util.NavigableMap @CheckForNull public Map.Entry firstEntry() { return (Map.Entry) Iterators.getNext(entryIterator(), null); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lastEntry() { return (Map.Entry) Iterators.getNext(descendingEntryIterator(), null); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollFirstEntry() { return (Map.Entry) Iterators.pollNext(entryIterator()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollLastEntry() { return (Map.Entry) Iterators.pollNext(descendingEntryIterator()); } @Override // java.util.SortedMap @ParametricNullness public K firstKey() { Map.Entry firstEntry = firstEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return firstEntry.getKey(); } @Override // java.util.SortedMap @ParametricNullness public K lastKey() { Map.Entry lastEntry = lastEntry(); if (lastEntry == null) { throw new NoSuchElementException(); } return lastEntry.getKey(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lowerEntry(@ParametricNullness K k) { return headMap(k, false).lastEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry floorEntry(@ParametricNullness K k) { return headMap(k, true).lastEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry ceilingEntry(@ParametricNullness K k) { return tailMap(k, true).firstEntry(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry higherEntry(@ParametricNullness K k) { return tailMap(k, false).firstEntry(); } @Override // java.util.NavigableMap @CheckForNull public K lowerKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(lowerEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K floorKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(floorEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K ceilingKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(ceilingEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public K higherKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(higherEntry(k)); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap subMap(@ParametricNullness K k, @ParametricNullness K k2) { return subMap(k, true, k2, false); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap headMap(@ParametricNullness K k) { return headMap(k, false); } @Override // java.util.NavigableMap, java.util.SortedMap public SortedMap tailMap(@ParametricNullness K k) { return tailMap(k, true); } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return new Maps.NavigableKeySet(this); } @Override // java.util.AbstractMap, java.util.Map, java.util.SortedMap public Set keySet() { return navigableKeySet(); } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return descendingMap().navigableKeySet(); } @Override // java.util.NavigableMap public NavigableMap descendingMap() { return new DescendingMap(); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public final class DescendingMap extends Maps.DescendingMap { @Override // com.google.common.collect.Maps.DescendingMap NavigableMap forward() { return AbstractNavigableMap.this; } private DescendingMap() { } @Override // com.google.common.collect.Maps.DescendingMap Iterator> entryIterator() { return AbstractNavigableMap.this.descendingEntryIterator(); } } }