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; /* loaded from: classes2.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 public Map.Entry lowerEntry(K k) { return delegate().lowerEntry(k); } protected Map.Entry standardLowerEntry(K k) { return headMap(k, false).lastEntry(); } @Override // java.util.NavigableMap public K lowerKey(K k) { return delegate().lowerKey(k); } protected K standardLowerKey(K k) { return (K) Maps.keyOrNull(lowerEntry(k)); } @Override // java.util.NavigableMap public Map.Entry floorEntry(K k) { return delegate().floorEntry(k); } protected Map.Entry standardFloorEntry(K k) { return headMap(k, true).lastEntry(); } @Override // java.util.NavigableMap public K floorKey(K k) { return delegate().floorKey(k); } protected K standardFloorKey(K k) { return (K) Maps.keyOrNull(floorEntry(k)); } @Override // java.util.NavigableMap public Map.Entry ceilingEntry(K k) { return delegate().ceilingEntry(k); } protected Map.Entry standardCeilingEntry(K k) { return tailMap(k, true).firstEntry(); } @Override // java.util.NavigableMap public K ceilingKey(K k) { return delegate().ceilingKey(k); } protected K standardCeilingKey(K k) { return (K) Maps.keyOrNull(ceilingEntry(k)); } @Override // java.util.NavigableMap public Map.Entry higherEntry(K k) { return delegate().higherEntry(k); } protected Map.Entry standardHigherEntry(K k) { return tailMap(k, false).firstEntry(); } @Override // java.util.NavigableMap public K higherKey(K k) { return delegate().higherKey(k); } protected K standardHigherKey(K k) { return (K) Maps.keyOrNull(higherEntry(k)); } @Override // java.util.NavigableMap public Map.Entry firstEntry() { return delegate().firstEntry(); } 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 public Map.Entry lastEntry() { return delegate().lastEntry(); } 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 public Map.Entry pollFirstEntry() { return delegate().pollFirstEntry(); } protected Map.Entry standardPollFirstEntry() { return (Map.Entry) Iterators.pollNext(entrySet().iterator()); } @Override // java.util.NavigableMap public Map.Entry pollLastEntry() { return delegate().pollLastEntry(); } 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: classes2.dex */ public class StandardDescendingMap extends Maps.DescendingMap { final ForwardingNavigableMap this$0; public StandardDescendingMap(ForwardingNavigableMap forwardingNavigableMap) { this.this$0 = forwardingNavigableMap; } @Override // com.google.common.collect.Maps.DescendingMap protected Iterator> entryIterator() { return new Iterator>(this) { // from class: com.google.common.collect.ForwardingNavigableMap.StandardDescendingMap.1 private Map.Entry nextOrNull; final StandardDescendingMap this$1; private Map.Entry toRemove = null; { this.this$1 = this; this.nextOrNull = this.forward().lastEntry(); } @Override // java.util.Iterator public Map.Entry next() { if (!hasNext()) { throw new NoSuchElementException(); } try { Map.Entry entry = this.nextOrNull; this.toRemove = entry; this.nextOrNull = this.this$1.forward().lowerEntry(this.nextOrNull.getKey()); return entry; } catch (Throwable th) { this.toRemove = this.nextOrNull; this.nextOrNull = this.this$1.forward().lowerEntry(this.nextOrNull.getKey()); throw th; } } @Override // java.util.Iterator public void remove() { CollectPreconditions.checkRemove(this.toRemove != null); this.this$1.forward().remove(this.toRemove.getKey()); this.toRemove = null; } @Override // java.util.Iterator public boolean hasNext() { return this.nextOrNull != null; } }; } @Override // com.google.common.collect.Maps.DescendingMap NavigableMap forward() { return this.this$0; } } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return delegate().navigableKeySet(); } /* loaded from: classes2.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(K k, K k2) { return subMap(k, true, k2, false); } @Override // java.util.NavigableMap public NavigableMap subMap(K k, boolean z, K k2, boolean z2) { return delegate().subMap(k, z, k2, z2); } @Override // java.util.NavigableMap public NavigableMap headMap(K k, boolean z) { return delegate().headMap(k, z); } @Override // java.util.NavigableMap public NavigableMap tailMap(K k, boolean z) { return delegate().tailMap(k, z); } protected SortedMap standardHeadMap(K k) { return headMap(k, false); } protected SortedMap standardTailMap(K k) { return tailMap(k, true); } }