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.SortedMap; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public abstract class ForwardingNavigableMap extends ForwardingSortedMap implements NavigableMap { /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingSortedMap, com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject public abstract NavigableMap delegate(); protected ForwardingNavigableMap() { } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lowerEntry(@ParametricNullness K k) { return delegate().lowerEntry(k); } @CheckForNull protected Map.Entry standardLowerEntry(@ParametricNullness K k) { return headMap(k, false).lastEntry(); } @Override // java.util.NavigableMap @CheckForNull public K lowerKey(@ParametricNullness K k) { return delegate().lowerKey(k); } @CheckForNull protected K standardLowerKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(lowerEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry floorEntry(@ParametricNullness K k) { return delegate().floorEntry(k); } @CheckForNull protected Map.Entry standardFloorEntry(@ParametricNullness K k) { return headMap(k, true).lastEntry(); } @Override // java.util.NavigableMap @CheckForNull public K floorKey(@ParametricNullness K k) { return delegate().floorKey(k); } @CheckForNull protected K standardFloorKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(floorEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry ceilingEntry(@ParametricNullness K k) { return delegate().ceilingEntry(k); } @CheckForNull protected Map.Entry standardCeilingEntry(@ParametricNullness K k) { return tailMap(k, true).firstEntry(); } @Override // java.util.NavigableMap @CheckForNull public K ceilingKey(@ParametricNullness K k) { return delegate().ceilingKey(k); } @CheckForNull protected K standardCeilingKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(ceilingEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry higherEntry(@ParametricNullness K k) { return delegate().higherEntry(k); } @CheckForNull protected Map.Entry standardHigherEntry(@ParametricNullness K k) { return tailMap(k, false).firstEntry(); } @Override // java.util.NavigableMap @CheckForNull public K higherKey(@ParametricNullness K k) { return delegate().higherKey(k); } @CheckForNull protected K standardHigherKey(@ParametricNullness K k) { return (K) Maps.keyOrNull(higherEntry(k)); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry firstEntry() { return delegate().firstEntry(); } @CheckForNull protected Map.Entry standardFirstEntry() { return (Map.Entry) Iterables.getFirst(entrySet(), null); } protected K standardFirstKey() { Map.Entry firstEntry = firstEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return firstEntry.getKey(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry lastEntry() { return delegate().lastEntry(); } @CheckForNull protected Map.Entry standardLastEntry() { return (Map.Entry) Iterables.getFirst(descendingMap().entrySet(), null); } protected K standardLastKey() { Map.Entry lastEntry = lastEntry(); if (lastEntry == null) { throw new NoSuchElementException(); } return lastEntry.getKey(); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollFirstEntry() { return delegate().pollFirstEntry(); } @CheckForNull protected Map.Entry standardPollFirstEntry() { return (Map.Entry) Iterators.pollNext(entrySet().iterator()); } @Override // java.util.NavigableMap @CheckForNull public Map.Entry pollLastEntry() { return delegate().pollLastEntry(); } @CheckForNull protected Map.Entry standardPollLastEntry() { return (Map.Entry) Iterators.pollNext(descendingMap().entrySet().iterator()); } @Override // java.util.NavigableMap public NavigableMap descendingMap() { return delegate().descendingMap(); } /* JADX INFO: Access modifiers changed from: protected */ /* loaded from: classes3.dex */ public class StandardDescendingMap extends Maps.DescendingMap { @Override // com.google.common.collect.Maps.DescendingMap NavigableMap forward() { return ForwardingNavigableMap.this; } public StandardDescendingMap() { } @Override // com.google.common.collect.Maps.DescendingMap protected Iterator> entryIterator() { return new Iterator>() { // from class: com.google.common.collect.ForwardingNavigableMap.StandardDescendingMap.1 @CheckForNull private Map.Entry nextOrNull; @CheckForNull private Map.Entry toRemove = null; @Override // java.util.Iterator public boolean hasNext() { return this.nextOrNull != null; } { this.nextOrNull = StandardDescendingMap.this.forward().lastEntry(); } @Override // java.util.Iterator public Map.Entry next() { Map.Entry entry = this.nextOrNull; if (entry == null) { throw new NoSuchElementException(); } this.toRemove = entry; this.nextOrNull = StandardDescendingMap.this.forward().lowerEntry(this.nextOrNull.getKey()); return entry; } @Override // java.util.Iterator public void remove() { if (this.toRemove == null) { throw new IllegalStateException("no calls to next() since the last call to remove()"); } StandardDescendingMap.this.forward().remove(this.toRemove.getKey()); this.toRemove = null; } }; } } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return delegate().navigableKeySet(); } /* loaded from: classes3.dex */ protected class StandardNavigableKeySet extends Maps.NavigableKeySet { public StandardNavigableKeySet(ForwardingNavigableMap forwardingNavigableMap) { super(forwardingNavigableMap); } } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return delegate().descendingKeySet(); } protected NavigableSet standardDescendingKeySet() { return descendingMap().navigableKeySet(); } @Override // com.google.common.collect.ForwardingSortedMap protected SortedMap standardSubMap(@ParametricNullness K k, @ParametricNullness K k2) { return subMap(k, true, k2, false); } @Override // java.util.NavigableMap public NavigableMap subMap(@ParametricNullness K k, boolean z, @ParametricNullness K k2, boolean z2) { return delegate().subMap(k, z, k2, z2); } @Override // java.util.NavigableMap public NavigableMap headMap(@ParametricNullness K k, boolean z) { return delegate().headMap(k, z); } @Override // java.util.NavigableMap public NavigableMap tailMap(@ParametricNullness K k, boolean z) { return delegate().tailMap(k, z); } protected SortedMap standardHeadMap(@ParametricNullness K k) { return headMap(k, false); } protected SortedMap standardTailMap(@ParametricNullness K k) { return tailMap(k, true); } }