what-the-bank/sources/com/google/common/collect/ForwardingNavigableMap.java

256 lines
7.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
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<K, V> extends ForwardingSortedMap<K, V> implements NavigableMap<K, V> {
/* 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<K, V> delegate();
protected ForwardingNavigableMap() {
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lowerEntry(K k) {
return delegate().lowerEntry(k);
}
protected Map.Entry<K, V> 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<K, V> floorEntry(K k) {
return delegate().floorEntry(k);
}
protected Map.Entry<K, V> 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<K, V> ceilingEntry(K k) {
return delegate().ceilingEntry(k);
}
protected Map.Entry<K, V> 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<K, V> higherEntry(K k) {
return delegate().higherEntry(k);
}
protected Map.Entry<K, V> 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<K, V> firstEntry() {
return delegate().firstEntry();
}
protected Map.Entry<K, V> standardFirstEntry() {
return (Map.Entry) Iterables.getFirst(entrySet(), null);
}
protected K standardFirstKey() {
Map.Entry<K, V> firstEntry = firstEntry();
if (firstEntry == null) {
throw new NoSuchElementException();
}
return firstEntry.getKey();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lastEntry() {
return delegate().lastEntry();
}
protected Map.Entry<K, V> standardLastEntry() {
return (Map.Entry) Iterables.getFirst(descendingMap().entrySet(), null);
}
protected K standardLastKey() {
Map.Entry<K, V> lastEntry = lastEntry();
if (lastEntry == null) {
throw new NoSuchElementException();
}
return lastEntry.getKey();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> pollFirstEntry() {
return delegate().pollFirstEntry();
}
protected Map.Entry<K, V> standardPollFirstEntry() {
return (Map.Entry) Iterators.pollNext(entrySet().iterator());
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> pollLastEntry() {
return delegate().pollLastEntry();
}
protected Map.Entry<K, V> standardPollLastEntry() {
return (Map.Entry) Iterators.pollNext(descendingMap().entrySet().iterator());
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> descendingMap() {
return delegate().descendingMap();
}
/* JADX INFO: Access modifiers changed from: protected */
/* loaded from: classes2.dex */
public class StandardDescendingMap extends Maps.DescendingMap<K, V> {
final ForwardingNavigableMap this$0;
public StandardDescendingMap(ForwardingNavigableMap forwardingNavigableMap) {
this.this$0 = forwardingNavigableMap;
}
@Override // com.google.common.collect.Maps.DescendingMap
protected Iterator<Map.Entry<K, V>> entryIterator() {
return new Iterator<Map.Entry<K, V>>(this) { // from class: com.google.common.collect.ForwardingNavigableMap.StandardDescendingMap.1
private Map.Entry<K, V> nextOrNull;
final StandardDescendingMap this$1;
private Map.Entry<K, V> toRemove = null;
{
this.this$1 = this;
this.nextOrNull = this.forward().lastEntry();
}
@Override // java.util.Iterator
public Map.Entry<K, V> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
try {
Map.Entry<K, V> 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<K, V> forward() {
return this.this$0;
}
}
@Override // java.util.NavigableMap
public NavigableSet<K> navigableKeySet() {
return delegate().navigableKeySet();
}
/* loaded from: classes2.dex */
protected class StandardNavigableKeySet extends Maps.NavigableKeySet<K, V> {
public StandardNavigableKeySet(ForwardingNavigableMap forwardingNavigableMap) {
super(forwardingNavigableMap);
}
}
@Override // java.util.NavigableMap
public NavigableSet<K> descendingKeySet() {
return delegate().descendingKeySet();
}
protected NavigableSet<K> standardDescendingKeySet() {
return descendingMap().navigableKeySet();
}
@Override // com.google.common.collect.ForwardingSortedMap
protected SortedMap<K, V> standardSubMap(K k, K k2) {
return subMap(k, true, k2, false);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> subMap(K k, boolean z, K k2, boolean z2) {
return delegate().subMap(k, z, k2, z2);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> headMap(K k, boolean z) {
return delegate().headMap(k, z);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> tailMap(K k, boolean z) {
return delegate().tailMap(k, z);
}
protected SortedMap<K, V> standardHeadMap(K k) {
return headMap(k, false);
}
protected SortedMap<K, V> standardTailMap(K k) {
return tailMap(k, true);
}
}