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

2957 lines
116 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import com.google.common.base.Converter;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.MapDifference;
import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Properties;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/* loaded from: classes2.dex */
public final class Maps {
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public enum EntryFunction implements Function<Map.Entry<?, ?>, Object> {
KEY { // from class: com.google.common.collect.Maps.EntryFunction.1
@Override // com.google.common.base.Function
public final Object apply(Map.Entry<?, ?> entry) {
return entry.getKey();
}
},
VALUE { // from class: com.google.common.collect.Maps.EntryFunction.2
@Override // com.google.common.base.Function
public final Object apply(Map.Entry<?, ?> entry) {
return entry.getValue();
}
}
}
/* loaded from: classes2.dex */
public interface EntryTransformer<K, V1, V2> {
V2 transformEntry(K k, V1 v1);
}
private Maps() {
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K> Function<Map.Entry<K, ?>, K> keyFunction() {
return EntryFunction.KEY;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <V> Function<Map.Entry<?, V>, V> valueFunction() {
return EntryFunction.VALUE;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> Iterator<K> keyIterator(Iterator<Map.Entry<K, V>> it) {
return new TransformedIterator<Map.Entry<K, V>, K>(it) { // from class: com.google.common.collect.Maps.1
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.TransformedIterator
public K transform(Map.Entry<K, V> entry) {
return entry.getKey();
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> Iterator<V> valueIterator(Iterator<Map.Entry<K, V>> it) {
return new TransformedIterator<Map.Entry<K, V>, V>(it) { // from class: com.google.common.collect.Maps.2
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.TransformedIterator
public V transform(Map.Entry<K, V> entry) {
return entry.getValue();
}
};
}
public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(Map<K, ? extends V> map) {
if (map instanceof ImmutableEnumMap) {
return (ImmutableEnumMap) map;
}
Iterator<Map.Entry<K, ? extends V>> it = map.entrySet().iterator();
if (!it.hasNext()) {
return ImmutableMap.of();
}
Map.Entry<K, ? extends V> next = it.next();
K key = next.getKey();
V value = next.getValue();
CollectPreconditions.checkEntryNotNull(key, value);
EnumMap enumMap = new EnumMap(key.getDeclaringClass());
enumMap.put((EnumMap) key, (K) value);
while (it.hasNext()) {
Map.Entry<K, ? extends V> next2 = it.next();
K key2 = next2.getKey();
V value2 = next2.getValue();
CollectPreconditions.checkEntryNotNull(key2, value2);
enumMap.put((EnumMap) key2, (K) value2);
}
return ImmutableEnumMap.asImmutable(enumMap);
}
public static <K, V> HashMap<K, V> newHashMap() {
return new HashMap<>();
}
public static <K, V> HashMap<K, V> newHashMap(Map<? extends K, ? extends V> map) {
return new HashMap<>(map);
}
public static <K, V> HashMap<K, V> newHashMapWithExpectedSize(int i) {
return new HashMap<>(capacity(i));
}
/* JADX INFO: Access modifiers changed from: package-private */
public static int capacity(int i) {
if (i < 3) {
CollectPreconditions.checkNonnegative(i, "expectedSize");
return i + 1;
}
if (i < 1073741824) {
return (int) ((i / 0.75f) + 1.0f);
}
return Integer.MAX_VALUE;
}
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<>();
}
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(Map<? extends K, ? extends V> map) {
return new LinkedHashMap<>(map);
}
public static <K, V> LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int i) {
return new LinkedHashMap<>(capacity(i));
}
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
return new ConcurrentHashMap();
}
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
return new TreeMap<>();
}
public static <K, V> TreeMap<K, V> newTreeMap(SortedMap<K, ? extends V> sortedMap) {
return new TreeMap<>((SortedMap) sortedMap);
}
public static <C, K extends C, V> TreeMap<K, V> newTreeMap(Comparator<C> comparator) {
return new TreeMap<>(comparator);
}
public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Class<K> cls) {
return new EnumMap<>((Class) Preconditions.checkNotNull(cls));
}
public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Map<K, ? extends V> map) {
return new EnumMap<>(map);
}
public static <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<>();
}
public static <K, V> MapDifference<K, V> difference(Map<? extends K, ? extends V> map, Map<? extends K, ? extends V> map2) {
if (map instanceof SortedMap) {
return difference((SortedMap) map, (Map) map2);
}
return difference(map, map2, Equivalence.equals());
}
public static <K, V> MapDifference<K, V> difference(Map<? extends K, ? extends V> map, Map<? extends K, ? extends V> map2, Equivalence<? super V> equivalence) {
Preconditions.checkNotNull(equivalence);
LinkedHashMap newLinkedHashMap = newLinkedHashMap();
LinkedHashMap linkedHashMap = new LinkedHashMap(map2);
LinkedHashMap newLinkedHashMap2 = newLinkedHashMap();
LinkedHashMap newLinkedHashMap3 = newLinkedHashMap();
doDifference(map, map2, equivalence, newLinkedHashMap, linkedHashMap, newLinkedHashMap2, newLinkedHashMap3);
return new MapDifferenceImpl(newLinkedHashMap, linkedHashMap, newLinkedHashMap2, newLinkedHashMap3);
}
public static <K, V> SortedMapDifference<K, V> difference(SortedMap<K, ? extends V> sortedMap, Map<? extends K, ? extends V> map) {
Preconditions.checkNotNull(sortedMap);
Preconditions.checkNotNull(map);
Comparator orNaturalOrder = orNaturalOrder(sortedMap.comparator());
TreeMap newTreeMap = newTreeMap(orNaturalOrder);
TreeMap newTreeMap2 = newTreeMap(orNaturalOrder);
newTreeMap2.putAll(map);
TreeMap newTreeMap3 = newTreeMap(orNaturalOrder);
TreeMap newTreeMap4 = newTreeMap(orNaturalOrder);
doDifference(sortedMap, map, Equivalence.equals(), newTreeMap, newTreeMap2, newTreeMap3, newTreeMap4);
return new SortedMapDifferenceImpl(newTreeMap, newTreeMap2, newTreeMap3, newTreeMap4);
}
/* JADX WARN: Multi-variable type inference failed */
private static <K, V> void doDifference(Map<? extends K, ? extends V> map, Map<? extends K, ? extends V> map2, Equivalence<? super V> equivalence, Map<K, V> map3, Map<K, V> map4, Map<K, V> map5, Map<K, MapDifference.ValueDifference<V>> map6) {
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
K key = entry.getKey();
V value = entry.getValue();
if (map2.containsKey(key)) {
V remove = map4.remove(key);
if (equivalence.equivalent(value, remove)) {
map5.put(key, value);
} else {
map6.put(key, ValueDifferenceImpl.create(value, remove));
}
} else {
map3.put(key, value);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public static <K, V> Map<K, V> unmodifiableMap(Map<K, ? extends V> map) {
if (map instanceof SortedMap) {
return Collections.unmodifiableSortedMap((SortedMap) map);
}
return Collections.unmodifiableMap(map);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class MapDifferenceImpl<K, V> implements MapDifference<K, V> {
final Map<K, MapDifference.ValueDifference<V>> differences;
final Map<K, V> onBoth;
final Map<K, V> onlyOnLeft;
final Map<K, V> onlyOnRight;
MapDifferenceImpl(Map<K, V> map, Map<K, V> map2, Map<K, V> map3, Map<K, MapDifference.ValueDifference<V>> map4) {
this.onlyOnLeft = Maps.unmodifiableMap(map);
this.onlyOnRight = Maps.unmodifiableMap(map2);
this.onBoth = Maps.unmodifiableMap(map3);
this.differences = Maps.unmodifiableMap(map4);
}
@Override // com.google.common.collect.MapDifference
public boolean areEqual() {
return this.onlyOnLeft.isEmpty() && this.onlyOnRight.isEmpty() && this.differences.isEmpty();
}
@Override // com.google.common.collect.MapDifference
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof MapDifference)) {
return false;
}
MapDifference mapDifference = (MapDifference) obj;
return entriesOnlyOnLeft().equals(mapDifference.entriesOnlyOnLeft()) && entriesOnlyOnRight().equals(mapDifference.entriesOnlyOnRight()) && entriesInCommon().equals(mapDifference.entriesInCommon()) && entriesDiffering().equals(mapDifference.entriesDiffering());
}
@Override // com.google.common.collect.MapDifference
public int hashCode() {
return Objects.hashCode(entriesOnlyOnLeft(), entriesOnlyOnRight(), entriesInCommon(), entriesDiffering());
}
public String toString() {
if (areEqual()) {
return "equal";
}
StringBuilder sb = new StringBuilder("not equal");
if (!this.onlyOnLeft.isEmpty()) {
sb.append(": only on left=");
sb.append(this.onlyOnLeft);
}
if (!this.onlyOnRight.isEmpty()) {
sb.append(": only on right=");
sb.append(this.onlyOnRight);
}
if (!this.differences.isEmpty()) {
sb.append(": value differences=");
sb.append(this.differences);
}
return sb.toString();
}
@Override // com.google.common.collect.MapDifference
public Map<K, V> entriesOnlyOnRight() {
return this.onlyOnRight;
}
@Override // com.google.common.collect.MapDifference
public Map<K, V> entriesOnlyOnLeft() {
return this.onlyOnLeft;
}
@Override // com.google.common.collect.MapDifference
public Map<K, V> entriesInCommon() {
return this.onBoth;
}
@Override // com.google.common.collect.MapDifference
public Map<K, MapDifference.ValueDifference<V>> entriesDiffering() {
return this.differences;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class ValueDifferenceImpl<V> implements MapDifference.ValueDifference<V> {
private final V left;
private final V right;
static <V> MapDifference.ValueDifference<V> create(V v, V v2) {
return new ValueDifferenceImpl(v, v2);
}
private ValueDifferenceImpl(V v, V v2) {
this.left = v;
this.right = v2;
}
@Override // com.google.common.collect.MapDifference.ValueDifference
public boolean equals(Object obj) {
if (!(obj instanceof MapDifference.ValueDifference)) {
return false;
}
MapDifference.ValueDifference valueDifference = (MapDifference.ValueDifference) obj;
return Objects.equal(this.left, valueDifference.leftValue()) && Objects.equal(this.right, valueDifference.rightValue());
}
@Override // com.google.common.collect.MapDifference.ValueDifference
public int hashCode() {
return Objects.hashCode(this.left, this.right);
}
public String toString() {
String valueOf = String.valueOf(this.left);
String valueOf2 = String.valueOf(this.right);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 4 + String.valueOf(valueOf2).length());
sb.append("(");
sb.append(valueOf);
sb.append(", ");
sb.append(valueOf2);
sb.append(")");
return sb.toString();
}
@Override // com.google.common.collect.MapDifference.ValueDifference
public V rightValue() {
return this.right;
}
@Override // com.google.common.collect.MapDifference.ValueDifference
public V leftValue() {
return this.left;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class SortedMapDifferenceImpl<K, V> extends MapDifferenceImpl<K, V> implements SortedMapDifference<K, V> {
SortedMapDifferenceImpl(SortedMap<K, V> sortedMap, SortedMap<K, V> sortedMap2, SortedMap<K, V> sortedMap3, SortedMap<K, MapDifference.ValueDifference<V>> sortedMap4) {
super(sortedMap, sortedMap2, sortedMap3, sortedMap4);
}
@Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference
public SortedMap<K, MapDifference.ValueDifference<V>> entriesDiffering() {
return (SortedMap) super.entriesDiffering();
}
@Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference
public SortedMap<K, V> entriesInCommon() {
return (SortedMap) super.entriesInCommon();
}
@Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference
public SortedMap<K, V> entriesOnlyOnLeft() {
return (SortedMap) super.entriesOnlyOnLeft();
}
@Override // com.google.common.collect.Maps.MapDifferenceImpl, com.google.common.collect.MapDifference
public SortedMap<K, V> entriesOnlyOnRight() {
return (SortedMap) super.entriesOnlyOnRight();
}
}
static <E> Comparator<? super E> orNaturalOrder(Comparator<? super E> comparator) {
return comparator != null ? comparator : Ordering.natural();
}
public static <K, V> Map<K, V> asMap(Set<K> set, Function<? super K, V> function) {
return new AsMapView(set, function);
}
public static <K, V> SortedMap<K, V> asMap(SortedSet<K> sortedSet, Function<? super K, V> function) {
return new SortedAsMapView(sortedSet, function);
}
public static <K, V> NavigableMap<K, V> asMap(NavigableSet<K> navigableSet, Function<? super K, V> function) {
return new NavigableAsMapView(navigableSet, function);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class AsMapView<K, V> extends ViewCachingAbstractMap<K, V> {
final Function<? super K, V> function;
private final Set<K> set;
AsMapView(Set<K> set, Function<? super K, V> function) {
this.set = (Set) Preconditions.checkNotNull(set);
this.function = (Function) Preconditions.checkNotNull(function);
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
public Set<K> createKeySet() {
return Maps.removeOnlySet(backingSet());
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Collection<V> createValues() {
return Collections2.transform(this.set, this.function);
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return backingSet().size();
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return backingSet().contains(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
if (Collections2.safeContains(backingSet(), obj)) {
return this.function.apply(obj);
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
if (backingSet().remove(obj)) {
return this.function.apply(obj);
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
backingSet().clear();
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
protected Set<Map.Entry<K, V>> createEntrySet() {
return new EntrySet<K, V>(this) { // from class: com.google.common.collect.Maps.AsMapView.1EntrySetImpl
final AsMapView this$0;
{
this.this$0 = this;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return Maps.asMapEntryIterator(this.this$0.backingSet(), this.this$0.function);
}
@Override // com.google.common.collect.Maps.EntrySet
Map<K, V> map() {
return this.this$0;
}
};
}
Set<K> backingSet() {
return this.set;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> Iterator<Map.Entry<K, V>> asMapEntryIterator(Set<K> set, Function<? super K, V> function) {
return new TransformedIterator<K, Map.Entry<K, V>>(set.iterator(), function) { // from class: com.google.common.collect.Maps.3
final Function val$function;
{
this.val$function = function;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.TransformedIterator
public /* bridge */ /* synthetic */ Object transform(Object obj) {
return transform((AnonymousClass3<K, V>) obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.TransformedIterator
public Map.Entry<K, V> transform(K k) {
return Maps.immutableEntry(k, this.val$function.apply(k));
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class SortedAsMapView<K, V> extends AsMapView<K, V> implements SortedMap<K, V> {
SortedAsMapView(SortedSet<K> sortedSet, Function<? super K, V> function) {
super(sortedSet, function);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.AsMapView
public SortedSet<K> backingSet() {
return (SortedSet) super.backingSet();
}
@Override // java.util.SortedMap
public Comparator<? super K> comparator() {
return backingSet().comparator();
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
return Maps.removeOnlySortedSet(backingSet());
}
@Override // java.util.SortedMap
public SortedMap<K, V> subMap(K k, K k2) {
return Maps.asMap((SortedSet) backingSet().subSet(k, k2), (Function) this.function);
}
@Override // java.util.SortedMap
public SortedMap<K, V> headMap(K k) {
return Maps.asMap((SortedSet) backingSet().headSet(k), (Function) this.function);
}
@Override // java.util.SortedMap
public SortedMap<K, V> tailMap(K k) {
return Maps.asMap((SortedSet) backingSet().tailSet(k), (Function) this.function);
}
@Override // java.util.SortedMap
public K firstKey() {
return backingSet().first();
}
@Override // java.util.SortedMap
public K lastKey() {
return backingSet().last();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class NavigableAsMapView<K, V> extends AbstractNavigableMap<K, V> {
private final Function<? super K, V> function;
private final NavigableSet<K> set;
NavigableAsMapView(NavigableSet<K> navigableSet, Function<? super K, V> function) {
this.set = (NavigableSet) Preconditions.checkNotNull(navigableSet);
this.function = (Function) Preconditions.checkNotNull(function);
}
@Override // java.util.NavigableMap
public final NavigableMap<K, V> subMap(K k, boolean z, K k2, boolean z2) {
return Maps.asMap((NavigableSet) this.set.subSet(k, z, k2, z2), (Function) this.function);
}
@Override // java.util.NavigableMap
public final NavigableMap<K, V> headMap(K k, boolean z) {
return Maps.asMap((NavigableSet) this.set.headSet(k, z), (Function) this.function);
}
@Override // java.util.NavigableMap
public final NavigableMap<K, V> tailMap(K k, boolean z) {
return Maps.asMap((NavigableSet) this.set.tailSet(k, z), (Function) this.function);
}
@Override // java.util.SortedMap
public final Comparator<? super K> comparator() {
return this.set.comparator();
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map
public final V get(Object obj) {
if (Collections2.safeContains(this.set, obj)) {
return this.function.apply(obj);
}
return null;
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public final void clear() {
this.set.clear();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
public final Iterator<Map.Entry<K, V>> entryIterator() {
return Maps.asMapEntryIterator(this.set, this.function);
}
@Override // com.google.common.collect.AbstractNavigableMap
final Iterator<Map.Entry<K, V>> descendingEntryIterator() {
return descendingMap().entrySet().iterator();
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public final NavigableSet<K> navigableKeySet() {
return Maps.removeOnlyNavigableSet(this.set);
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public final int size() {
return this.set.size();
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public final NavigableMap<K, V> descendingMap() {
return Maps.asMap((NavigableSet) this.set.descendingSet(), (Function) this.function);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static <E> Set<E> removeOnlySet(Set<E> set) {
return new ForwardingSet<E>(set) { // from class: com.google.common.collect.Maps.4
final Set val$set;
{
this.val$set = set;
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue
public boolean add(E e) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection
public boolean addAll(Collection<? extends E> collection) {
throw new UnsupportedOperationException();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
public Set<E> delegate() {
return this.val$set;
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public static <E> SortedSet<E> removeOnlySortedSet(SortedSet<E> sortedSet) {
return new ForwardingSortedSet<E>(sortedSet) { // from class: com.google.common.collect.Maps.5
final SortedSet val$set;
{
this.val$set = sortedSet;
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue
public boolean add(E e) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection
public boolean addAll(Collection<? extends E> collection) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> headSet(E e) {
return Maps.removeOnlySortedSet(super.headSet(e));
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> subSet(E e, E e2) {
return Maps.removeOnlySortedSet(super.subSet(e, e2));
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> tailSet(E e) {
return Maps.removeOnlySortedSet(super.tailSet(e));
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingSortedSet, com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
public SortedSet<E> delegate() {
return this.val$set;
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public static <E> NavigableSet<E> removeOnlyNavigableSet(NavigableSet<E> navigableSet) {
return new ForwardingNavigableSet<E>(navigableSet) { // from class: com.google.common.collect.Maps.6
final NavigableSet val$set;
{
this.val$set = navigableSet;
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Queue
public boolean add(E e) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection
public boolean addAll(Collection<? extends E> collection) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> headSet(E e) {
return Maps.removeOnlySortedSet(super.headSet(e));
}
@Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet
public NavigableSet<E> headSet(E e, boolean z) {
return Maps.removeOnlyNavigableSet(super.headSet(e, z));
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> subSet(E e, E e2) {
return Maps.removeOnlySortedSet(super.subSet(e, e2));
}
@Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet
public NavigableSet<E> subSet(E e, boolean z, E e2, boolean z2) {
return Maps.removeOnlyNavigableSet(super.subSet(e, z, e2, z2));
}
@Override // com.google.common.collect.ForwardingSortedSet, java.util.SortedSet
public SortedSet<E> tailSet(E e) {
return Maps.removeOnlySortedSet(super.tailSet(e));
}
@Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet
public NavigableSet<E> tailSet(E e, boolean z) {
return Maps.removeOnlyNavigableSet(super.tailSet(e, z));
}
@Override // com.google.common.collect.ForwardingNavigableSet, java.util.NavigableSet
public NavigableSet<E> descendingSet() {
return Maps.removeOnlyNavigableSet(super.descendingSet());
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingNavigableSet, com.google.common.collect.ForwardingSortedSet, com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
public NavigableSet<E> delegate() {
return this.val$set;
}
};
}
public static <K, V> ImmutableMap<K, V> toMap(Iterable<K> iterable, Function<? super K, V> function) {
return toMap(iterable.iterator(), function);
}
public static <K, V> ImmutableMap<K, V> toMap(Iterator<K> it, Function<? super K, V> function) {
Preconditions.checkNotNull(function);
LinkedHashMap newLinkedHashMap = newLinkedHashMap();
while (it.hasNext()) {
K next = it.next();
newLinkedHashMap.put(next, function.apply(next));
}
return ImmutableMap.copyOf((Map) newLinkedHashMap);
}
public static <K, V> ImmutableMap<K, V> uniqueIndex(Iterable<V> iterable, Function<? super V, K> function) {
return uniqueIndex(iterable.iterator(), function);
}
public static <K, V> ImmutableMap<K, V> uniqueIndex(Iterator<V> it, Function<? super V, K> function) {
Preconditions.checkNotNull(function);
ImmutableMap.Builder builder = ImmutableMap.builder();
while (it.hasNext()) {
V next = it.next();
builder.put(function.apply(next), next);
}
try {
return builder.build();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.valueOf(e.getMessage()).concat(". To index multiple values under a key, use Multimaps.index."));
}
}
public static ImmutableMap<String, String> fromProperties(Properties properties) {
ImmutableMap.Builder builder = ImmutableMap.builder();
Enumeration<?> propertyNames = properties.propertyNames();
while (propertyNames.hasMoreElements()) {
String str = (String) propertyNames.nextElement();
builder.put(str, properties.getProperty(str));
}
return builder.build();
}
public static <K, V> Map.Entry<K, V> immutableEntry(K k, V v) {
return new ImmutableEntry(k, v);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> Set<Map.Entry<K, V>> unmodifiableEntrySet(Set<Map.Entry<K, V>> set) {
return new UnmodifiableEntrySet(Collections.unmodifiableSet(set));
}
static <K, V> Map.Entry<K, V> unmodifiableEntry(Map.Entry<? extends K, ? extends V> entry) {
Preconditions.checkNotNull(entry);
return new AbstractMapEntry<K, V>(entry) { // from class: com.google.common.collect.Maps.7
final Map.Entry val$entry;
{
this.val$entry = entry;
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public K getKey() {
return (K) this.val$entry.getKey();
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public V getValue() {
return (V) this.val$entry.getValue();
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> UnmodifiableIterator<Map.Entry<K, V>> unmodifiableEntryIterator(Iterator<Map.Entry<K, V>> it) {
return new UnmodifiableIterator<Map.Entry<K, V>>(it) { // from class: com.google.common.collect.Maps.8
final Iterator val$entryIterator;
{
this.val$entryIterator = it;
}
@Override // java.util.Iterator
public boolean hasNext() {
return this.val$entryIterator.hasNext();
}
@Override // java.util.Iterator
public Map.Entry<K, V> next() {
return Maps.unmodifiableEntry((Map.Entry) this.val$entryIterator.next());
}
};
}
/* loaded from: classes2.dex */
static class UnmodifiableEntries<K, V> extends ForwardingCollection<Map.Entry<K, V>> {
private final Collection<Map.Entry<K, V>> entries;
/* JADX INFO: Access modifiers changed from: package-private */
public UnmodifiableEntries(Collection<Map.Entry<K, V>> collection) {
this.entries = collection;
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return Maps.unmodifiableEntryIterator(this.entries.iterator());
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set
public Object[] toArray() {
return standardToArray();
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set
public <T> T[] toArray(T[] tArr) {
return (T[]) standardToArray(tArr);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
public Collection<Map.Entry<K, V>> delegate() {
return this.entries;
}
}
/* loaded from: classes2.dex */
static class UnmodifiableEntrySet<K, V> extends UnmodifiableEntries<K, V> implements Set<Map.Entry<K, V>> {
UnmodifiableEntrySet(Set<Map.Entry<K, V>> set) {
super(set);
}
@Override // java.util.Collection, java.util.Set
public boolean equals(Object obj) {
return Sets.equalsImpl(this, obj);
}
@Override // java.util.Collection, java.util.Set
public int hashCode() {
return Sets.hashCodeImpl(this);
}
}
public static <A, B> Converter<A, B> asConverter(BiMap<A, B> biMap) {
return new BiMapConverter(biMap);
}
/* loaded from: classes2.dex */
static final class BiMapConverter<A, B> extends Converter<A, B> implements Serializable {
private static final long serialVersionUID = 0;
private final BiMap<A, B> bimap;
BiMapConverter(BiMap<A, B> biMap) {
this.bimap = (BiMap) Preconditions.checkNotNull(biMap);
}
@Override // com.google.common.base.Converter
public final B doForward(A a) {
return (B) convert(this.bimap, a);
}
@Override // com.google.common.base.Converter
public final A doBackward(B b) {
return (A) convert(this.bimap.inverse(), b);
}
private static <X, Y> Y convert(BiMap<X, Y> biMap, X x) {
Y y = biMap.get(x);
Preconditions.checkArgument(y != null, "No non-null mapping present for input: %s", x);
return y;
}
@Override // com.google.common.base.Converter, com.google.common.base.Function
public final boolean equals(Object obj) {
if (obj instanceof BiMapConverter) {
return this.bimap.equals(((BiMapConverter) obj).bimap);
}
return false;
}
public final int hashCode() {
return this.bimap.hashCode();
}
public final String toString() {
String valueOf = String.valueOf(this.bimap);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 18);
sb.append("Maps.asConverter(");
sb.append(valueOf);
sb.append(")");
return sb.toString();
}
}
public static <K, V> BiMap<K, V> synchronizedBiMap(BiMap<K, V> biMap) {
return Synchronized.biMap(biMap, null);
}
public static <K, V> BiMap<K, V> unmodifiableBiMap(BiMap<? extends K, ? extends V> biMap) {
return new UnmodifiableBiMap(biMap, null);
}
/* loaded from: classes2.dex */
static class UnmodifiableBiMap<K, V> extends ForwardingMap<K, V> implements BiMap<K, V>, Serializable {
private static final long serialVersionUID = 0;
final BiMap<? extends K, ? extends V> delegate;
BiMap<V, K> inverse;
final Map<K, V> unmodifiableMap;
transient Set<V> values;
UnmodifiableBiMap(BiMap<? extends K, ? extends V> biMap, BiMap<V, K> biMap2) {
this.unmodifiableMap = Collections.unmodifiableMap(biMap);
this.delegate = biMap;
this.inverse = biMap2;
}
@Override // com.google.common.collect.BiMap
public V forcePut(K k, V v) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.BiMap
public BiMap<V, K> inverse() {
BiMap<V, K> biMap = this.inverse;
if (biMap != null) {
return biMap;
}
UnmodifiableBiMap unmodifiableBiMap = new UnmodifiableBiMap(this.delegate.inverse(), this);
this.inverse = unmodifiableBiMap;
return unmodifiableBiMap;
}
@Override // com.google.common.collect.ForwardingMap, java.util.Map
public Set<V> values() {
Set<V> set = this.values;
if (set != null) {
return set;
}
Set<V> unmodifiableSet = Collections.unmodifiableSet(this.delegate.values());
this.values = unmodifiableSet;
return unmodifiableSet;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject
public Map<K, V> delegate() {
return this.unmodifiableMap;
}
}
public static <K, V1, V2> Map<K, V2> transformValues(Map<K, V1> map, Function<? super V1, V2> function) {
return transformEntries(map, asEntryTransformer(function));
}
public static <K, V1, V2> SortedMap<K, V2> transformValues(SortedMap<K, V1> sortedMap, Function<? super V1, V2> function) {
return transformEntries((SortedMap) sortedMap, asEntryTransformer(function));
}
public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> navigableMap, Function<? super V1, V2> function) {
return transformEntries((NavigableMap) navigableMap, asEntryTransformer(function));
}
public static <K, V1, V2> Map<K, V2> transformEntries(Map<K, V1> map, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
return new TransformedEntriesMap(map, entryTransformer);
}
public static <K, V1, V2> SortedMap<K, V2> transformEntries(SortedMap<K, V1> sortedMap, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
return new TransformedEntriesSortedMap(sortedMap, entryTransformer);
}
public static <K, V1, V2> NavigableMap<K, V2> transformEntries(NavigableMap<K, V1> navigableMap, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
return new TransformedEntriesNavigableMap(navigableMap, entryTransformer);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V1, V2> EntryTransformer<K, V1, V2> asEntryTransformer(Function<? super V1, V2> function) {
Preconditions.checkNotNull(function);
return new EntryTransformer<K, V1, V2>(function) { // from class: com.google.common.collect.Maps.9
final Function val$function;
{
this.val$function = function;
}
@Override // com.google.common.collect.Maps.EntryTransformer
public V2 transformEntry(K k, V1 v1) {
return (V2) this.val$function.apply(v1);
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V1, V2> Function<V1, V2> asValueToValueFunction(EntryTransformer<? super K, V1, V2> entryTransformer, K k) {
Preconditions.checkNotNull(entryTransformer);
return new Function<V1, V2>(entryTransformer, k) { // from class: com.google.common.collect.Maps.10
final Object val$key;
final EntryTransformer val$transformer;
{
this.val$transformer = entryTransformer;
this.val$key = k;
}
@Override // com.google.common.base.Function
public V2 apply(V1 v1) {
return (V2) this.val$transformer.transformEntry(this.val$key, v1);
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V1, V2> Function<Map.Entry<K, V1>, V2> asEntryToValueFunction(EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
Preconditions.checkNotNull(entryTransformer);
return new Function<Map.Entry<K, V1>, V2>(entryTransformer) { // from class: com.google.common.collect.Maps.11
final EntryTransformer val$transformer;
{
this.val$transformer = entryTransformer;
}
@Override // com.google.common.base.Function
public V2 apply(Map.Entry<K, V1> entry) {
return (V2) this.val$transformer.transformEntry(entry.getKey(), entry.getValue());
}
};
}
static <V2, K, V1> Map.Entry<K, V2> transformEntry(EntryTransformer<? super K, ? super V1, V2> entryTransformer, Map.Entry<K, V1> entry) {
Preconditions.checkNotNull(entryTransformer);
Preconditions.checkNotNull(entry);
return new AbstractMapEntry<K, V2>(entry, entryTransformer) { // from class: com.google.common.collect.Maps.12
final Map.Entry val$entry;
final EntryTransformer val$transformer;
{
this.val$entry = entry;
this.val$transformer = entryTransformer;
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public K getKey() {
return (K) this.val$entry.getKey();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public V2 getValue() {
return (V2) this.val$transformer.transformEntry(this.val$entry.getKey(), this.val$entry.getValue());
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V1, V2> Function<Map.Entry<K, V1>, Map.Entry<K, V2>> asEntryToEntryFunction(EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
Preconditions.checkNotNull(entryTransformer);
return new Function<Map.Entry<K, V1>, Map.Entry<K, V2>>(entryTransformer) { // from class: com.google.common.collect.Maps.13
final EntryTransformer val$transformer;
{
this.val$transformer = entryTransformer;
}
@Override // com.google.common.base.Function
public Map.Entry<K, V2> apply(Map.Entry<K, V1> entry) {
return Maps.transformEntry(this.val$transformer, entry);
}
};
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class TransformedEntriesMap<K, V1, V2> extends IteratorBasedAbstractMap<K, V2> {
final Map<K, V1> fromMap;
final EntryTransformer<? super K, ? super V1, V2> transformer;
TransformedEntriesMap(Map<K, V1> map, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
this.fromMap = (Map) Preconditions.checkNotNull(map);
this.transformer = (EntryTransformer) Preconditions.checkNotNull(entryTransformer);
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public int size() {
return this.fromMap.size();
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return this.fromMap.containsKey(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public V2 get(Object obj) {
V1 v1 = this.fromMap.get(obj);
if (v1 != null || this.fromMap.containsKey(obj)) {
return this.transformer.transformEntry(obj, v1);
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public V2 remove(Object obj) {
if (this.fromMap.containsKey(obj)) {
return this.transformer.transformEntry(obj, this.fromMap.remove(obj));
}
return null;
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public void clear() {
this.fromMap.clear();
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
return this.fromMap.keySet();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
public Iterator<Map.Entry<K, V2>> entryIterator() {
return Iterators.transform(this.fromMap.entrySet().iterator(), Maps.asEntryToEntryFunction(this.transformer));
}
@Override // java.util.AbstractMap, java.util.Map
public Collection<V2> values() {
return new Values(this);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class TransformedEntriesSortedMap<K, V1, V2> extends TransformedEntriesMap<K, V1, V2> implements SortedMap<K, V2> {
protected SortedMap<K, V1> fromMap() {
return (SortedMap) this.fromMap;
}
TransformedEntriesSortedMap(SortedMap<K, V1> sortedMap, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
super(sortedMap, entryTransformer);
}
@Override // java.util.SortedMap
public Comparator<? super K> comparator() {
return fromMap().comparator();
}
@Override // java.util.SortedMap
public K firstKey() {
return fromMap().firstKey();
}
public SortedMap<K, V2> headMap(K k) {
return Maps.transformEntries((SortedMap) fromMap().headMap(k), (EntryTransformer) this.transformer);
}
@Override // java.util.SortedMap
public K lastKey() {
return fromMap().lastKey();
}
public SortedMap<K, V2> subMap(K k, K k2) {
return Maps.transformEntries((SortedMap) fromMap().subMap(k, k2), (EntryTransformer) this.transformer);
}
public SortedMap<K, V2> tailMap(K k) {
return Maps.transformEntries((SortedMap) fromMap().tailMap(k), (EntryTransformer) this.transformer);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class TransformedEntriesNavigableMap<K, V1, V2> extends TransformedEntriesSortedMap<K, V1, V2> implements NavigableMap<K, V2> {
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap
public /* bridge */ /* synthetic */ SortedMap headMap(Object obj) {
return headMap((TransformedEntriesNavigableMap<K, V1, V2>) obj);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap
public /* bridge */ /* synthetic */ SortedMap tailMap(Object obj) {
return tailMap((TransformedEntriesNavigableMap<K, V1, V2>) obj);
}
TransformedEntriesNavigableMap(NavigableMap<K, V1> navigableMap, EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
super(navigableMap, entryTransformer);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> ceilingEntry(K k) {
return transformEntry(fromMap().ceilingEntry(k));
}
@Override // java.util.NavigableMap
public K ceilingKey(K k) {
return fromMap().ceilingKey(k);
}
@Override // java.util.NavigableMap
public NavigableSet<K> descendingKeySet() {
return fromMap().descendingKeySet();
}
@Override // java.util.NavigableMap
public NavigableMap<K, V2> descendingMap() {
return Maps.transformEntries((NavigableMap) fromMap().descendingMap(), (EntryTransformer) this.transformer);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> firstEntry() {
return transformEntry(fromMap().firstEntry());
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> floorEntry(K k) {
return transformEntry(fromMap().floorEntry(k));
}
@Override // java.util.NavigableMap
public K floorKey(K k) {
return fromMap().floorKey(k);
}
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap
public NavigableMap<K, V2> headMap(K k) {
return headMap(k, false);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V2> headMap(K k, boolean z) {
return Maps.transformEntries((NavigableMap) fromMap().headMap(k, z), (EntryTransformer) this.transformer);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> higherEntry(K k) {
return transformEntry(fromMap().higherEntry(k));
}
@Override // java.util.NavigableMap
public K higherKey(K k) {
return fromMap().higherKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> lastEntry() {
return transformEntry(fromMap().lastEntry());
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> lowerEntry(K k) {
return transformEntry(fromMap().lowerEntry(k));
}
@Override // java.util.NavigableMap
public K lowerKey(K k) {
return fromMap().lowerKey(k);
}
@Override // java.util.NavigableMap
public NavigableSet<K> navigableKeySet() {
return fromMap().navigableKeySet();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> pollFirstEntry() {
return transformEntry(fromMap().pollFirstEntry());
}
@Override // java.util.NavigableMap
public Map.Entry<K, V2> pollLastEntry() {
return transformEntry(fromMap().pollLastEntry());
}
@Override // java.util.NavigableMap
public NavigableMap<K, V2> subMap(K k, boolean z, K k2, boolean z2) {
return Maps.transformEntries((NavigableMap) fromMap().subMap(k, z, k2, z2), (EntryTransformer) this.transformer);
}
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap
public NavigableMap<K, V2> subMap(K k, K k2) {
return subMap(k, true, k2, false);
}
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap, java.util.SortedMap, java.util.NavigableMap
public NavigableMap<K, V2> tailMap(K k) {
return tailMap(k, true);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V2> tailMap(K k, boolean z) {
return Maps.transformEntries((NavigableMap) fromMap().tailMap(k, z), (EntryTransformer) this.transformer);
}
private Map.Entry<K, V2> transformEntry(Map.Entry<K, V1> entry) {
if (entry == null) {
return null;
}
return Maps.transformEntry(this.transformer, entry);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.Maps.TransformedEntriesSortedMap
public NavigableMap<K, V1> fromMap() {
return (NavigableMap) super.fromMap();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K> Predicate<Map.Entry<K, ?>> keyPredicateOnEntries(Predicate<? super K> predicate) {
return Predicates.compose(predicate, keyFunction());
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <V> Predicate<Map.Entry<?, V>> valuePredicateOnEntries(Predicate<? super V> predicate) {
return Predicates.compose(predicate, valueFunction());
}
public static <K, V> Map<K, V> filterKeys(Map<K, V> map, Predicate<? super K> predicate) {
Preconditions.checkNotNull(predicate);
Predicate keyPredicateOnEntries = keyPredicateOnEntries(predicate);
if (map instanceof AbstractFilteredMap) {
return filterFiltered((AbstractFilteredMap) map, keyPredicateOnEntries);
}
return new FilteredKeyMap((Map) Preconditions.checkNotNull(map), predicate, keyPredicateOnEntries);
}
public static <K, V> SortedMap<K, V> filterKeys(SortedMap<K, V> sortedMap, Predicate<? super K> predicate) {
return filterEntries((SortedMap) sortedMap, keyPredicateOnEntries(predicate));
}
public static <K, V> NavigableMap<K, V> filterKeys(NavigableMap<K, V> navigableMap, Predicate<? super K> predicate) {
return filterEntries((NavigableMap) navigableMap, keyPredicateOnEntries(predicate));
}
public static <K, V> BiMap<K, V> filterKeys(BiMap<K, V> biMap, Predicate<? super K> predicate) {
Preconditions.checkNotNull(predicate);
return filterEntries((BiMap) biMap, keyPredicateOnEntries(predicate));
}
public static <K, V> Map<K, V> filterValues(Map<K, V> map, Predicate<? super V> predicate) {
return filterEntries(map, valuePredicateOnEntries(predicate));
}
public static <K, V> SortedMap<K, V> filterValues(SortedMap<K, V> sortedMap, Predicate<? super V> predicate) {
return filterEntries((SortedMap) sortedMap, valuePredicateOnEntries(predicate));
}
public static <K, V> NavigableMap<K, V> filterValues(NavigableMap<K, V> navigableMap, Predicate<? super V> predicate) {
return filterEntries((NavigableMap) navigableMap, valuePredicateOnEntries(predicate));
}
public static <K, V> BiMap<K, V> filterValues(BiMap<K, V> biMap, Predicate<? super V> predicate) {
return filterEntries((BiMap) biMap, valuePredicateOnEntries(predicate));
}
public static <K, V> Map<K, V> filterEntries(Map<K, V> map, Predicate<? super Map.Entry<K, V>> predicate) {
Preconditions.checkNotNull(predicate);
if (map instanceof AbstractFilteredMap) {
return filterFiltered((AbstractFilteredMap) map, predicate);
}
return new FilteredEntryMap((Map) Preconditions.checkNotNull(map), predicate);
}
public static <K, V> SortedMap<K, V> filterEntries(SortedMap<K, V> sortedMap, Predicate<? super Map.Entry<K, V>> predicate) {
Preconditions.checkNotNull(predicate);
if (sortedMap instanceof FilteredEntrySortedMap) {
return filterFiltered((FilteredEntrySortedMap) sortedMap, (Predicate) predicate);
}
return new FilteredEntrySortedMap((SortedMap) Preconditions.checkNotNull(sortedMap), predicate);
}
public static <K, V> NavigableMap<K, V> filterEntries(NavigableMap<K, V> navigableMap, Predicate<? super Map.Entry<K, V>> predicate) {
Preconditions.checkNotNull(predicate);
if (navigableMap instanceof FilteredEntryNavigableMap) {
return filterFiltered((FilteredEntryNavigableMap) navigableMap, predicate);
}
return new FilteredEntryNavigableMap((NavigableMap) Preconditions.checkNotNull(navigableMap), predicate);
}
public static <K, V> BiMap<K, V> filterEntries(BiMap<K, V> biMap, Predicate<? super Map.Entry<K, V>> predicate) {
Preconditions.checkNotNull(biMap);
Preconditions.checkNotNull(predicate);
if (biMap instanceof FilteredEntryBiMap) {
return filterFiltered((FilteredEntryBiMap) biMap, (Predicate) predicate);
}
return new FilteredEntryBiMap(biMap, predicate);
}
private static <K, V> Map<K, V> filterFiltered(AbstractFilteredMap<K, V> abstractFilteredMap, Predicate<? super Map.Entry<K, V>> predicate) {
return new FilteredEntryMap(abstractFilteredMap.unfiltered, Predicates.and(abstractFilteredMap.predicate, predicate));
}
private static <K, V> SortedMap<K, V> filterFiltered(FilteredEntrySortedMap<K, V> filteredEntrySortedMap, Predicate<? super Map.Entry<K, V>> predicate) {
return new FilteredEntrySortedMap(filteredEntrySortedMap.sortedMap(), Predicates.and(filteredEntrySortedMap.predicate, predicate));
}
private static <K, V> NavigableMap<K, V> filterFiltered(FilteredEntryNavigableMap<K, V> filteredEntryNavigableMap, Predicate<? super Map.Entry<K, V>> predicate) {
return new FilteredEntryNavigableMap(((FilteredEntryNavigableMap) filteredEntryNavigableMap).unfiltered, Predicates.and(((FilteredEntryNavigableMap) filteredEntryNavigableMap).entryPredicate, predicate));
}
private static <K, V> BiMap<K, V> filterFiltered(FilteredEntryBiMap<K, V> filteredEntryBiMap, Predicate<? super Map.Entry<K, V>> predicate) {
return new FilteredEntryBiMap(filteredEntryBiMap.unfiltered(), Predicates.and(filteredEntryBiMap.predicate, predicate));
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class AbstractFilteredMap<K, V> extends ViewCachingAbstractMap<K, V> {
final Predicate<? super Map.Entry<K, V>> predicate;
final Map<K, V> unfiltered;
AbstractFilteredMap(Map<K, V> map, Predicate<? super Map.Entry<K, V>> predicate) {
this.unfiltered = map;
this.predicate = predicate;
}
boolean apply(Object obj, V v) {
return this.predicate.apply(Maps.immutableEntry(obj, v));
}
@Override // java.util.AbstractMap, java.util.Map
public V put(K k, V v) {
Preconditions.checkArgument(apply(k, v));
return this.unfiltered.put(k, v);
}
@Override // java.util.AbstractMap, java.util.Map
public void putAll(Map<? extends K, ? extends V> map) {
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
Preconditions.checkArgument(apply(entry.getKey(), entry.getValue()));
}
this.unfiltered.putAll(map);
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return this.unfiltered.containsKey(obj) && apply(obj, this.unfiltered.get(obj));
}
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
V v = this.unfiltered.get(obj);
if (v == null || !apply(obj, v)) {
return null;
}
return v;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean isEmpty() {
return entrySet().isEmpty();
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
if (containsKey(obj)) {
return this.unfiltered.remove(obj);
}
return null;
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Collection<V> createValues() {
return new FilteredMapValues(this, this.unfiltered, this.predicate);
}
}
/* loaded from: classes2.dex */
static final class FilteredMapValues<K, V> extends Values<K, V> {
final Predicate<? super Map.Entry<K, V>> predicate;
final Map<K, V> unfiltered;
FilteredMapValues(Map<K, V> map, Map<K, V> map2, Predicate<? super Map.Entry<K, V>> predicate) {
super(map);
this.unfiltered = map2;
this.predicate = predicate;
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public final boolean remove(Object obj) {
Iterator<Map.Entry<K, V>> it = this.unfiltered.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<K, V> next = it.next();
if (this.predicate.apply(next) && Objects.equal(next.getValue(), obj)) {
it.remove();
return true;
}
}
return false;
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public final boolean removeAll(Collection<?> collection) {
Iterator<Map.Entry<K, V>> it = this.unfiltered.entrySet().iterator();
boolean z = false;
while (it.hasNext()) {
Map.Entry<K, V> next = it.next();
if (this.predicate.apply(next) && collection.contains(next.getValue())) {
it.remove();
z = true;
}
}
return z;
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public final boolean retainAll(Collection<?> collection) {
Iterator<Map.Entry<K, V>> it = this.unfiltered.entrySet().iterator();
boolean z = false;
while (it.hasNext()) {
Map.Entry<K, V> next = it.next();
if (this.predicate.apply(next) && !collection.contains(next.getValue())) {
it.remove();
z = true;
}
}
return z;
}
@Override // java.util.AbstractCollection, java.util.Collection
public final Object[] toArray() {
return Lists.newArrayList(iterator()).toArray();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final <T> T[] toArray(T[] tArr) {
return (T[]) Lists.newArrayList(iterator()).toArray(tArr);
}
}
/* loaded from: classes2.dex */
static class FilteredKeyMap<K, V> extends AbstractFilteredMap<K, V> {
final Predicate<? super K> keyPredicate;
FilteredKeyMap(Map<K, V> map, Predicate<? super K> predicate, Predicate<? super Map.Entry<K, V>> predicate2) {
super(map, predicate2);
this.keyPredicate = predicate;
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
protected Set<Map.Entry<K, V>> createEntrySet() {
return Sets.filter(this.unfiltered.entrySet(), this.predicate);
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Set<K> createKeySet() {
return Sets.filter(this.unfiltered.keySet(), this.keyPredicate);
}
@Override // com.google.common.collect.Maps.AbstractFilteredMap, java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return this.unfiltered.containsKey(obj) && this.keyPredicate.apply(obj);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class FilteredEntryMap<K, V> extends AbstractFilteredMap<K, V> {
final Set<Map.Entry<K, V>> filteredEntrySet;
FilteredEntryMap(Map<K, V> map, Predicate<? super Map.Entry<K, V>> predicate) {
super(map, predicate);
this.filteredEntrySet = Sets.filter(map.entrySet(), this.predicate);
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
protected Set<Map.Entry<K, V>> createEntrySet() {
return new EntrySet();
}
/* loaded from: classes2.dex */
class EntrySet extends ForwardingSet<Map.Entry<K, V>> {
final FilteredEntryMap this$0;
private EntrySet(FilteredEntryMap filteredEntryMap) {
this.this$0 = filteredEntryMap;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingSet, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
public Set<Map.Entry<K, V>> delegate() {
return this.this$0.filteredEntrySet;
}
/* renamed from: com.google.common.collect.Maps$FilteredEntryMap$EntrySet$1, reason: invalid class name */
/* loaded from: classes2.dex */
class AnonymousClass1 extends TransformedIterator<Map.Entry<K, V>, Map.Entry<K, V>> {
final EntrySet this$1;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
AnonymousClass1(EntrySet entrySet, Iterator it) {
super(it);
this.this$1 = entrySet;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.TransformedIterator
public Map.Entry<K, V> transform(Map.Entry<K, V> entry) {
return new ForwardingMapEntry<K, V>(this, entry) { // from class: com.google.common.collect.Maps.FilteredEntryMap.EntrySet.1.1
final AnonymousClass1 this$2;
final Map.Entry val$entry;
{
this.this$2 = this;
this.val$entry = entry;
}
@Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry
public V setValue(V v) {
Preconditions.checkArgument(this.this$2.this$1.this$0.apply(getKey(), v));
return (V) super.setValue(v);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingMapEntry, com.google.common.collect.ForwardingObject
public Map.Entry<K, V> delegate() {
return this.val$entry;
}
};
}
}
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return new AnonymousClass1(this, this.this$0.filteredEntrySet.iterator());
}
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Set<K> createKeySet() {
return new KeySet(this);
}
static <K, V> boolean removeAllKeys(Map<K, V> map, Predicate<? super Map.Entry<K, V>> predicate, Collection<?> collection) {
Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
boolean z = false;
while (it.hasNext()) {
Map.Entry<K, V> next = it.next();
if (predicate.apply(next) && collection.contains(next.getKey())) {
it.remove();
z = true;
}
}
return z;
}
static <K, V> boolean retainAllKeys(Map<K, V> map, Predicate<? super Map.Entry<K, V>> predicate, Collection<?> collection) {
Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
boolean z = false;
while (it.hasNext()) {
Map.Entry<K, V> next = it.next();
if (predicate.apply(next) && !collection.contains(next.getKey())) {
it.remove();
z = true;
}
}
return z;
}
/* loaded from: classes2.dex */
class KeySet extends KeySet<K, V> {
final FilteredEntryMap this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
KeySet(FilteredEntryMap filteredEntryMap) {
super(filteredEntryMap);
this.this$0 = filteredEntryMap;
}
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
if (!this.this$0.containsKey(obj)) {
return false;
}
this.this$0.unfiltered.remove(obj);
return true;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
return FilteredEntryMap.removeAllKeys(this.this$0.unfiltered, this.this$0.predicate, collection);
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
return FilteredEntryMap.retainAllKeys(this.this$0.unfiltered, this.this$0.predicate, collection);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public Object[] toArray() {
return Lists.newArrayList(iterator()).toArray();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public <T> T[] toArray(T[] tArr) {
return (T[]) Lists.newArrayList(iterator()).toArray(tArr);
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class FilteredEntrySortedMap<K, V> extends FilteredEntryMap<K, V> implements SortedMap<K, V> {
FilteredEntrySortedMap(SortedMap<K, V> sortedMap, Predicate<? super Map.Entry<K, V>> predicate) {
super(sortedMap, predicate);
}
SortedMap<K, V> sortedMap() {
return (SortedMap) this.unfiltered;
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
public SortedSet<K> keySet() {
return (SortedSet) super.keySet();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.FilteredEntryMap, com.google.common.collect.Maps.ViewCachingAbstractMap
public SortedSet<K> createKeySet() {
return new SortedKeySet(this);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class SortedKeySet extends FilteredEntryMap.KeySet implements SortedSet {
final FilteredEntrySortedMap this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
SortedKeySet(FilteredEntrySortedMap filteredEntrySortedMap) {
super(filteredEntrySortedMap);
this.this$0 = filteredEntrySortedMap;
}
@Override // java.util.SortedSet
public Comparator<? super K> comparator() {
return this.this$0.sortedMap().comparator();
}
@Override // java.util.SortedSet
public SortedSet<K> subSet(K k, K k2) {
return (SortedSet) this.this$0.subMap(k, k2).keySet();
}
@Override // java.util.SortedSet
public SortedSet<K> headSet(K k) {
return (SortedSet) this.this$0.headMap(k).keySet();
}
@Override // java.util.SortedSet
public SortedSet<K> tailSet(K k) {
return (SortedSet) this.this$0.tailMap(k).keySet();
}
@Override // java.util.SortedSet
public K first() {
return (K) this.this$0.firstKey();
}
@Override // java.util.SortedSet
public K last() {
return (K) this.this$0.lastKey();
}
}
@Override // java.util.SortedMap
public Comparator<? super K> comparator() {
return sortedMap().comparator();
}
@Override // java.util.SortedMap
public K firstKey() {
return keySet().iterator().next();
}
@Override // java.util.SortedMap
public K lastKey() {
SortedMap<K, V> sortedMap = sortedMap();
while (true) {
K lastKey = sortedMap.lastKey();
if (apply(lastKey, this.unfiltered.get(lastKey))) {
return lastKey;
}
sortedMap = sortedMap().headMap(lastKey);
}
}
@Override // java.util.SortedMap
public SortedMap<K, V> headMap(K k) {
return new FilteredEntrySortedMap(sortedMap().headMap(k), this.predicate);
}
@Override // java.util.SortedMap
public SortedMap<K, V> subMap(K k, K k2) {
return new FilteredEntrySortedMap(sortedMap().subMap(k, k2), this.predicate);
}
@Override // java.util.SortedMap
public SortedMap<K, V> tailMap(K k) {
return new FilteredEntrySortedMap(sortedMap().tailMap(k), this.predicate);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class FilteredEntryNavigableMap<K, V> extends AbstractNavigableMap<K, V> {
private final Predicate<? super Map.Entry<K, V>> entryPredicate;
private final Map<K, V> filteredDelegate;
private final NavigableMap<K, V> unfiltered;
FilteredEntryNavigableMap(NavigableMap<K, V> navigableMap, Predicate<? super Map.Entry<K, V>> predicate) {
this.unfiltered = (NavigableMap) Preconditions.checkNotNull(navigableMap);
this.entryPredicate = predicate;
this.filteredDelegate = new FilteredEntryMap(navigableMap, predicate);
}
@Override // java.util.SortedMap
public Comparator<? super K> comparator() {
return this.unfiltered.comparator();
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public NavigableSet<K> navigableKeySet() {
return new NavigableKeySet<K, V>(this, this) { // from class: com.google.common.collect.Maps.FilteredEntryNavigableMap.1
final FilteredEntryNavigableMap this$0;
{
this.this$0 = this;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
return FilteredEntryMap.removeAllKeys(this.this$0.unfiltered, this.this$0.entryPredicate, collection);
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
return FilteredEntryMap.retainAllKeys(this.this$0.unfiltered, this.this$0.entryPredicate, collection);
}
};
}
@Override // java.util.AbstractMap, java.util.Map, java.util.SortedMap
public Collection<V> values() {
return new FilteredMapValues(this, this.unfiltered, this.entryPredicate);
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
Iterator<Map.Entry<K, V>> entryIterator() {
return Iterators.filter(this.unfiltered.entrySet().iterator(), this.entryPredicate);
}
@Override // com.google.common.collect.AbstractNavigableMap
Iterator<Map.Entry<K, V>> descendingEntryIterator() {
return Iterators.filter(this.unfiltered.descendingMap().entrySet().iterator(), this.entryPredicate);
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public int size() {
return this.filteredDelegate.size();
}
@Override // java.util.AbstractMap, java.util.Map
public boolean isEmpty() {
return !Iterables.any(this.unfiltered.entrySet(), this.entryPredicate);
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map
public V get(Object obj) {
return this.filteredDelegate.get(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return this.filteredDelegate.containsKey(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public V put(K k, V v) {
return this.filteredDelegate.put(k, v);
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
return this.filteredDelegate.remove(obj);
}
@Override // java.util.AbstractMap, java.util.Map
public void putAll(Map<? extends K, ? extends V> map) {
this.filteredDelegate.putAll(map);
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public void clear() {
this.filteredDelegate.clear();
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map, java.util.SortedMap
public Set<Map.Entry<K, V>> entrySet() {
return this.filteredDelegate.entrySet();
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public Map.Entry<K, V> pollFirstEntry() {
return (Map.Entry) Iterables.removeFirstMatching(this.unfiltered.entrySet(), this.entryPredicate);
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public Map.Entry<K, V> pollLastEntry() {
return (Map.Entry) Iterables.removeFirstMatching(this.unfiltered.descendingMap().entrySet(), this.entryPredicate);
}
@Override // com.google.common.collect.AbstractNavigableMap, java.util.NavigableMap
public NavigableMap<K, V> descendingMap() {
return Maps.filterEntries((NavigableMap) this.unfiltered.descendingMap(), (Predicate) this.entryPredicate);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> subMap(K k, boolean z, K k2, boolean z2) {
return Maps.filterEntries((NavigableMap) this.unfiltered.subMap(k, z, k2, z2), (Predicate) this.entryPredicate);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> headMap(K k, boolean z) {
return Maps.filterEntries((NavigableMap) this.unfiltered.headMap(k, z), (Predicate) this.entryPredicate);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> tailMap(K k, boolean z) {
return Maps.filterEntries((NavigableMap) this.unfiltered.tailMap(k, z), (Predicate) this.entryPredicate);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class FilteredEntryBiMap<K, V> extends FilteredEntryMap<K, V> implements BiMap<K, V> {
private final BiMap<V, K> inverse;
private static <K, V> Predicate<Map.Entry<V, K>> inversePredicate(Predicate<? super Map.Entry<K, V>> predicate) {
return new Predicate<Map.Entry<V, K>>(predicate) { // from class: com.google.common.collect.Maps.FilteredEntryBiMap.1
final Predicate val$forwardPredicate;
{
this.val$forwardPredicate = predicate;
}
@Override // com.google.common.base.Predicate
public boolean apply(Map.Entry<V, K> entry) {
return this.val$forwardPredicate.apply(Maps.immutableEntry(entry.getValue(), entry.getKey()));
}
};
}
FilteredEntryBiMap(BiMap<K, V> biMap, Predicate<? super Map.Entry<K, V>> predicate) {
super(biMap, predicate);
this.inverse = new FilteredEntryBiMap(biMap.inverse(), inversePredicate(predicate), this);
}
private FilteredEntryBiMap(BiMap<K, V> biMap, Predicate<? super Map.Entry<K, V>> predicate, BiMap<V, K> biMap2) {
super(biMap, predicate);
this.inverse = biMap2;
}
final BiMap<K, V> unfiltered() {
return (BiMap) this.unfiltered;
}
@Override // com.google.common.collect.BiMap
public final V forcePut(K k, V v) {
Preconditions.checkArgument(apply(k, v));
return unfiltered().forcePut(k, v);
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
public final Set<V> values() {
return this.inverse.keySet();
}
@Override // com.google.common.collect.BiMap
public final BiMap<V, K> inverse() {
return this.inverse;
}
}
/* JADX WARN: Multi-variable type inference failed */
public static <K, V> NavigableMap<K, V> unmodifiableNavigableMap(NavigableMap<K, ? extends V> navigableMap) {
Preconditions.checkNotNull(navigableMap);
return navigableMap instanceof UnmodifiableNavigableMap ? navigableMap : new UnmodifiableNavigableMap(navigableMap);
}
/* JADX INFO: Access modifiers changed from: private */
public static <K, V> Map.Entry<K, V> unmodifiableOrNull(Map.Entry<K, ? extends V> entry) {
if (entry == null) {
return null;
}
return unmodifiableEntry(entry);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class UnmodifiableNavigableMap<K, V> extends ForwardingSortedMap<K, V> implements NavigableMap<K, V>, Serializable {
private final NavigableMap<K, ? extends V> delegate;
private transient UnmodifiableNavigableMap<K, V> descendingMap;
UnmodifiableNavigableMap(NavigableMap<K, ? extends V> navigableMap) {
this.delegate = navigableMap;
}
UnmodifiableNavigableMap(NavigableMap<K, ? extends V> navigableMap, UnmodifiableNavigableMap<K, V> unmodifiableNavigableMap) {
this.delegate = navigableMap;
this.descendingMap = unmodifiableNavigableMap;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingSortedMap, com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject
public SortedMap<K, V> delegate() {
return Collections.unmodifiableSortedMap(this.delegate);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lowerEntry(K k) {
return Maps.unmodifiableOrNull(this.delegate.lowerEntry(k));
}
@Override // java.util.NavigableMap
public K lowerKey(K k) {
return this.delegate.lowerKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> floorEntry(K k) {
return Maps.unmodifiableOrNull(this.delegate.floorEntry(k));
}
@Override // java.util.NavigableMap
public K floorKey(K k) {
return this.delegate.floorKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> ceilingEntry(K k) {
return Maps.unmodifiableOrNull(this.delegate.ceilingEntry(k));
}
@Override // java.util.NavigableMap
public K ceilingKey(K k) {
return this.delegate.ceilingKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> higherEntry(K k) {
return Maps.unmodifiableOrNull(this.delegate.higherEntry(k));
}
@Override // java.util.NavigableMap
public K higherKey(K k) {
return this.delegate.higherKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> firstEntry() {
return Maps.unmodifiableOrNull(this.delegate.firstEntry());
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lastEntry() {
return Maps.unmodifiableOrNull(this.delegate.lastEntry());
}
@Override // java.util.NavigableMap
public final Map.Entry<K, V> pollFirstEntry() {
throw new UnsupportedOperationException();
}
@Override // java.util.NavigableMap
public final Map.Entry<K, V> pollLastEntry() {
throw new UnsupportedOperationException();
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> descendingMap() {
UnmodifiableNavigableMap<K, V> unmodifiableNavigableMap = this.descendingMap;
if (unmodifiableNavigableMap != null) {
return unmodifiableNavigableMap;
}
UnmodifiableNavigableMap<K, V> unmodifiableNavigableMap2 = new UnmodifiableNavigableMap<>(this.delegate.descendingMap(), this);
this.descendingMap = unmodifiableNavigableMap2;
return unmodifiableNavigableMap2;
}
@Override // com.google.common.collect.ForwardingMap, java.util.Map
public Set<K> keySet() {
return navigableKeySet();
}
@Override // java.util.NavigableMap
public NavigableSet<K> navigableKeySet() {
return Sets.unmodifiableNavigableSet(this.delegate.navigableKeySet());
}
@Override // java.util.NavigableMap
public NavigableSet<K> descendingKeySet() {
return Sets.unmodifiableNavigableSet(this.delegate.descendingKeySet());
}
@Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap
public SortedMap<K, V> subMap(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 Maps.unmodifiableNavigableMap(this.delegate.subMap(k, z, k2, z2));
}
@Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap
public SortedMap<K, V> headMap(K k) {
return headMap(k, false);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> headMap(K k, boolean z) {
return Maps.unmodifiableNavigableMap(this.delegate.headMap(k, z));
}
@Override // com.google.common.collect.ForwardingSortedMap, java.util.SortedMap
public SortedMap<K, V> tailMap(K k) {
return tailMap(k, true);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> tailMap(K k, boolean z) {
return Maps.unmodifiableNavigableMap(this.delegate.tailMap(k, z));
}
}
public static <K, V> NavigableMap<K, V> synchronizedNavigableMap(NavigableMap<K, V> navigableMap) {
return Synchronized.navigableMap(navigableMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class ViewCachingAbstractMap<K, V> extends AbstractMap<K, V> {
private transient Set<Map.Entry<K, V>> entrySet;
private transient Set<K> keySet;
private transient Collection<V> values;
abstract Set<Map.Entry<K, V>> createEntrySet();
@Override // java.util.AbstractMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = this.entrySet;
if (set != null) {
return set;
}
Set<Map.Entry<K, V>> createEntrySet = createEntrySet();
this.entrySet = createEntrySet;
return createEntrySet;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
Set<K> set = this.keySet;
if (set != null) {
return set;
}
Set<K> createKeySet = createKeySet();
this.keySet = createKeySet;
return createKeySet;
}
Set<K> createKeySet() {
return new KeySet(this);
}
@Override // java.util.AbstractMap, java.util.Map
public Collection<V> values() {
Collection<V> collection = this.values;
if (collection != null) {
return collection;
}
Collection<V> createValues = createValues();
this.values = createValues;
return createValues;
}
Collection<V> createValues() {
return new Values(this);
}
}
/* loaded from: classes2.dex */
static abstract class IteratorBasedAbstractMap<K, V> extends AbstractMap<K, V> {
/* JADX INFO: Access modifiers changed from: package-private */
public abstract Iterator<Map.Entry<K, V>> entryIterator();
@Override // java.util.AbstractMap, java.util.Map
public abstract int size();
@Override // java.util.AbstractMap, java.util.Map, java.util.SortedMap
public Set<Map.Entry<K, V>> entrySet() {
return new EntrySet<K, V>(this) { // from class: com.google.common.collect.Maps.IteratorBasedAbstractMap.1
final IteratorBasedAbstractMap this$0;
{
this.this$0 = this;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return this.this$0.entryIterator();
}
@Override // com.google.common.collect.Maps.EntrySet
Map<K, V> map() {
return this.this$0;
}
};
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
Iterators.clear(entryIterator());
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <V> V safeGet(Map<?, V> map, Object obj) {
Preconditions.checkNotNull(map);
try {
return map.get(obj);
} catch (ClassCastException | NullPointerException unused) {
return null;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static boolean safeContainsKey(Map<?, ?> map, Object obj) {
Preconditions.checkNotNull(map);
try {
return map.containsKey(obj);
} catch (ClassCastException | NullPointerException unused) {
return false;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <V> V safeRemove(Map<?, V> map, Object obj) {
Preconditions.checkNotNull(map);
try {
return map.remove(obj);
} catch (ClassCastException | NullPointerException unused) {
return null;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static boolean containsKeyImpl(Map<?, ?> map, Object obj) {
return Iterators.contains(keyIterator(map.entrySet().iterator()), obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static boolean containsValueImpl(Map<?, ?> map, Object obj) {
return Iterators.contains(valueIterator(map.entrySet().iterator()), obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> boolean containsEntryImpl(Collection<Map.Entry<K, V>> collection, Object obj) {
if (obj instanceof Map.Entry) {
return collection.contains(unmodifiableEntry((Map.Entry) obj));
}
return false;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> boolean removeEntryImpl(Collection<Map.Entry<K, V>> collection, Object obj) {
if (obj instanceof Map.Entry) {
return collection.remove(unmodifiableEntry((Map.Entry) obj));
}
return false;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static boolean equalsImpl(Map<?, ?> map, Object obj) {
if (map == obj) {
return true;
}
if (obj instanceof Map) {
return map.entrySet().equals(((Map) obj).entrySet());
}
return false;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static String toStringImpl(Map<?, ?> map) {
StringBuilder newStringBuilderForCollection = Collections2.newStringBuilderForCollection(map.size());
newStringBuilderForCollection.append(UrlTreeKt.componentParamPrefixChar);
boolean z = true;
for (Map.Entry<?, ?> entry : map.entrySet()) {
if (!z) {
newStringBuilderForCollection.append(", ");
}
newStringBuilderForCollection.append(entry.getKey());
newStringBuilderForCollection.append('=');
newStringBuilderForCollection.append(entry.getValue());
z = false;
}
newStringBuilderForCollection.append(UrlTreeKt.componentParamSuffixChar);
return newStringBuilderForCollection.toString();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> void putAllImpl(Map<K, V> map, Map<? extends K, ? extends V> map2) {
for (Map.Entry<? extends K, ? extends V> entry : map2.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class KeySet<K, V> extends Sets.ImprovedAbstractSet<K> {
final Map<K, V> map;
/* JADX INFO: Access modifiers changed from: package-private */
public KeySet(Map<K, V> map) {
this.map = (Map) Preconditions.checkNotNull(map);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<K> iterator() {
return Maps.keyIterator(map().entrySet().iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return map().size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return map().isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return map().containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
if (!contains(obj)) {
return false;
}
map().remove(obj);
return true;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
map().clear();
}
/* JADX INFO: Access modifiers changed from: package-private */
public Map<K, V> map() {
return this.map;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K> K keyOrNull(Map.Entry<K, ?> entry) {
if (entry == null) {
return null;
}
return entry.getKey();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <V> V valueOrNull(Map.Entry<?, V> entry) {
if (entry == null) {
return null;
}
return entry.getValue();
}
/* loaded from: classes2.dex */
static class SortedKeySet<K, V> extends KeySet<K, V> implements SortedSet<K> {
/* JADX INFO: Access modifiers changed from: package-private */
public SortedKeySet(SortedMap<K, V> sortedMap) {
super(sortedMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.KeySet
public SortedMap<K, V> map() {
return (SortedMap) super.map();
}
@Override // java.util.SortedSet
public Comparator<? super K> comparator() {
return map().comparator();
}
public SortedSet<K> subSet(K k, K k2) {
return new SortedKeySet(map().subMap(k, k2));
}
public SortedSet<K> headSet(K k) {
return new SortedKeySet(map().headMap(k));
}
public SortedSet<K> tailSet(K k) {
return new SortedKeySet(map().tailMap(k));
}
@Override // java.util.SortedSet
public K first() {
return map().firstKey();
}
@Override // java.util.SortedSet
public K last() {
return map().lastKey();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class NavigableKeySet<K, V> extends SortedKeySet<K, V> implements NavigableSet<K> {
/* JADX INFO: Access modifiers changed from: package-private */
public NavigableKeySet(NavigableMap<K, V> navigableMap) {
super(navigableMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.SortedKeySet, com.google.common.collect.Maps.KeySet
public NavigableMap<K, V> map() {
return (NavigableMap) this.map;
}
@Override // java.util.NavigableSet
public K lower(K k) {
return map().lowerKey(k);
}
@Override // java.util.NavigableSet
public K floor(K k) {
return map().floorKey(k);
}
@Override // java.util.NavigableSet
public K ceiling(K k) {
return map().ceilingKey(k);
}
@Override // java.util.NavigableSet
public K higher(K k) {
return map().higherKey(k);
}
@Override // java.util.NavigableSet
public K pollFirst() {
return (K) Maps.keyOrNull(map().pollFirstEntry());
}
@Override // java.util.NavigableSet
public K pollLast() {
return (K) Maps.keyOrNull(map().pollLastEntry());
}
@Override // java.util.NavigableSet
public NavigableSet<K> descendingSet() {
return map().descendingKeySet();
}
@Override // java.util.NavigableSet
public Iterator<K> descendingIterator() {
return descendingSet().iterator();
}
@Override // java.util.NavigableSet
public NavigableSet<K> subSet(K k, boolean z, K k2, boolean z2) {
return map().subMap(k, z, k2, z2).navigableKeySet();
}
@Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
public SortedSet<K> subSet(K k, K k2) {
return subSet(k, true, k2, false);
}
@Override // java.util.NavigableSet
public NavigableSet<K> headSet(K k, boolean z) {
return map().headMap(k, z).navigableKeySet();
}
@Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
public SortedSet<K> headSet(K k) {
return headSet(k, false);
}
@Override // java.util.NavigableSet
public NavigableSet<K> tailSet(K k, boolean z) {
return map().tailMap(k, z).navigableKeySet();
}
@Override // com.google.common.collect.Maps.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
public SortedSet<K> tailSet(K k) {
return tailSet(k, true);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class Values<K, V> extends AbstractCollection<V> {
final Map<K, V> map;
/* JADX INFO: Access modifiers changed from: package-private */
public Values(Map<K, V> map) {
this.map = (Map) Preconditions.checkNotNull(map);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public Iterator<V> iterator() {
return Maps.valueIterator(map().entrySet().iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean remove(Object obj) {
try {
return super.remove(obj);
} catch (UnsupportedOperationException unused) {
for (Map.Entry<K, V> entry : map().entrySet()) {
if (Objects.equal(obj, entry.getValue())) {
map().remove(entry.getKey());
return true;
}
}
return false;
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean removeAll(Collection<?> collection) {
try {
return super.removeAll((Collection) Preconditions.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet newHashSet = Sets.newHashSet();
for (Map.Entry<K, V> entry : map().entrySet()) {
if (collection.contains(entry.getValue())) {
newHashSet.add(entry.getKey());
}
}
return map().keySet().removeAll(newHashSet);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean retainAll(Collection<?> collection) {
try {
return super.retainAll((Collection) Preconditions.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet newHashSet = Sets.newHashSet();
for (Map.Entry<K, V> entry : map().entrySet()) {
if (collection.contains(entry.getValue())) {
newHashSet.add(entry.getKey());
}
}
return map().keySet().retainAll(newHashSet);
}
}
@Override // java.util.AbstractCollection, java.util.Collection
public int size() {
return map().size();
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean isEmpty() {
return map().isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection
public boolean contains(Object obj) {
return map().containsValue(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection
public void clear() {
map().clear();
}
final Map<K, V> map() {
return this.map;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class EntrySet<K, V> extends Sets.ImprovedAbstractSet<Map.Entry<K, V>> {
abstract Map<K, V> map();
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return map().size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
map().clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
Object key = entry.getKey();
Object safeGet = Maps.safeGet(map(), key);
if (Objects.equal(safeGet, entry.getValue())) {
return safeGet != null || map().containsKey(key);
}
return false;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return map().isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
if (contains(obj)) {
return map().keySet().remove(((Map.Entry) obj).getKey());
}
return false;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
try {
return super.removeAll((Collection) Preconditions.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
return Sets.removeAllImpl(this, collection.iterator());
}
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
try {
return super.retainAll((Collection) Preconditions.checkNotNull(collection));
} catch (UnsupportedOperationException unused) {
HashSet newHashSetWithExpectedSize = Sets.newHashSetWithExpectedSize(collection.size());
for (Object obj : collection) {
if (contains(obj)) {
newHashSetWithExpectedSize.add(((Map.Entry) obj).getKey());
}
}
return map().keySet().retainAll(newHashSetWithExpectedSize);
}
}
}
/* loaded from: classes2.dex */
static abstract class DescendingMap<K, V> extends ForwardingMap<K, V> implements NavigableMap<K, V> {
private transient Comparator<? super K> comparator;
private transient Set<Map.Entry<K, V>> entrySet;
private transient NavigableSet<K> navigableKeySet;
abstract Iterator<Map.Entry<K, V>> entryIterator();
abstract NavigableMap<K, V> forward();
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject
public final Map<K, V> delegate() {
return forward();
}
@Override // java.util.SortedMap
public Comparator<? super K> comparator() {
Comparator<? super K> comparator = this.comparator;
if (comparator != null) {
return comparator;
}
Comparator<? super K> comparator2 = forward().comparator();
if (comparator2 == null) {
comparator2 = Ordering.natural();
}
Ordering reverse = reverse(comparator2);
this.comparator = reverse;
return reverse;
}
private static <T> Ordering<T> reverse(Comparator<T> comparator) {
return Ordering.from(comparator).reverse();
}
@Override // java.util.SortedMap
public K firstKey() {
return forward().lastKey();
}
@Override // java.util.SortedMap
public K lastKey() {
return forward().firstKey();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lowerEntry(K k) {
return forward().higherEntry(k);
}
@Override // java.util.NavigableMap
public K lowerKey(K k) {
return forward().higherKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> floorEntry(K k) {
return forward().ceilingEntry(k);
}
@Override // java.util.NavigableMap
public K floorKey(K k) {
return forward().ceilingKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> ceilingEntry(K k) {
return forward().floorEntry(k);
}
@Override // java.util.NavigableMap
public K ceilingKey(K k) {
return forward().floorKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> higherEntry(K k) {
return forward().lowerEntry(k);
}
@Override // java.util.NavigableMap
public K higherKey(K k) {
return forward().lowerKey(k);
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> firstEntry() {
return forward().lastEntry();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> lastEntry() {
return forward().firstEntry();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> pollFirstEntry() {
return forward().pollLastEntry();
}
@Override // java.util.NavigableMap
public Map.Entry<K, V> pollLastEntry() {
return forward().pollFirstEntry();
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> descendingMap() {
return forward();
}
@Override // com.google.common.collect.ForwardingMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = this.entrySet;
if (set != null) {
return set;
}
Set<Map.Entry<K, V>> createEntrySet = createEntrySet();
this.entrySet = createEntrySet;
return createEntrySet;
}
Set<Map.Entry<K, V>> createEntrySet() {
return new EntrySet<K, V>(this) { // from class: com.google.common.collect.Maps.DescendingMap.1EntrySetImpl
final DescendingMap this$0;
{
this.this$0 = this;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return this.this$0.entryIterator();
}
@Override // com.google.common.collect.Maps.EntrySet
Map<K, V> map() {
return this.this$0;
}
};
}
@Override // com.google.common.collect.ForwardingMap, java.util.Map
public Set<K> keySet() {
return navigableKeySet();
}
@Override // java.util.NavigableMap
public NavigableSet<K> navigableKeySet() {
NavigableSet<K> navigableSet = this.navigableKeySet;
if (navigableSet != null) {
return navigableSet;
}
NavigableKeySet navigableKeySet = new NavigableKeySet(this);
this.navigableKeySet = navigableKeySet;
return navigableKeySet;
}
@Override // java.util.NavigableMap
public NavigableSet<K> descendingKeySet() {
return forward().navigableKeySet();
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> subMap(K k, boolean z, K k2, boolean z2) {
return forward().subMap(k2, z2, k, z).descendingMap();
}
@Override // java.util.NavigableMap, java.util.SortedMap
public SortedMap<K, V> subMap(K k, K k2) {
return subMap(k, true, k2, false);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> headMap(K k, boolean z) {
return forward().tailMap(k, z).descendingMap();
}
@Override // java.util.NavigableMap, java.util.SortedMap
public SortedMap<K, V> headMap(K k) {
return headMap(k, false);
}
@Override // java.util.NavigableMap
public NavigableMap<K, V> tailMap(K k, boolean z) {
return forward().headMap(k, z).descendingMap();
}
@Override // java.util.NavigableMap, java.util.SortedMap
public SortedMap<K, V> tailMap(K k) {
return tailMap(k, true);
}
@Override // com.google.common.collect.ForwardingMap, java.util.Map
public Collection<V> values() {
return new Values(this);
}
@Override // com.google.common.collect.ForwardingObject
public String toString() {
return standardToString();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <E> ImmutableMap<E, Integer> indexMap(Collection<E> collection) {
ImmutableMap.Builder builder = new ImmutableMap.Builder(collection.size());
Iterator<E> it = collection.iterator();
int i = 0;
while (it.hasNext()) {
builder.put(it.next(), Integer.valueOf(i));
i++;
}
return builder.build();
}
public static <K extends Comparable<? super K>, V> NavigableMap<K, V> subMap(NavigableMap<K, V> navigableMap, Range<K> range) {
if (navigableMap.comparator() != null && navigableMap.comparator() != Ordering.natural() && range.hasLowerBound() && range.hasUpperBound()) {
Preconditions.checkArgument(navigableMap.comparator().compare(range.lowerEndpoint(), range.upperEndpoint()) <= 0, "map is using a custom comparator which is inconsistent with the natural ordering.");
}
if (range.hasLowerBound() && range.hasUpperBound()) {
return navigableMap.subMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED, range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED);
}
if (range.hasLowerBound()) {
return navigableMap.tailMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
}
if (range.hasUpperBound()) {
return navigableMap.headMap(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED);
}
return (NavigableMap) Preconditions.checkNotNull(navigableMap);
}
}