617 lines
26 KiB
Java
617 lines
26 KiB
Java
|
package com.google.common.collect;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import com.google.common.collect.ImmutableCollection;
|
||
|
import com.google.common.collect.ImmutableMap;
|
||
|
import java.util.AbstractMap;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Map;
|
||
|
import java.util.NavigableMap;
|
||
|
import java.util.Set;
|
||
|
import java.util.SortedMap;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V> implements NavigableMap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
private transient ImmutableSortedMap<K, V> descendingMap;
|
||
|
private final transient RegularImmutableSortedSet<K> keySet;
|
||
|
private final transient ImmutableList<V> valueList;
|
||
|
private static final Comparator<Comparable> NATURAL_ORDER = Ordering.natural();
|
||
|
private static final ImmutableSortedMap<Comparable, Object> NATURAL_EMPTY_MAP = new ImmutableSortedMap<>(ImmutableSortedSet.emptySet(Ordering.natural()), ImmutableList.of());
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final /* bridge */ /* synthetic */ Set entrySet() {
|
||
|
return entrySet();
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final /* bridge */ /* synthetic */ NavigableMap headMap(Object obj, boolean z) {
|
||
|
return headMap((ImmutableSortedMap<K, V>) obj, z);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap, java.util.SortedMap
|
||
|
public final /* bridge */ /* synthetic */ SortedMap headMap(Object obj) {
|
||
|
return headMap((ImmutableSortedMap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final /* bridge */ /* synthetic */ NavigableMap subMap(Object obj, boolean z, Object obj2, boolean z2) {
|
||
|
return subMap((boolean) obj, z, (boolean) obj2, z2);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final /* bridge */ /* synthetic */ NavigableMap tailMap(Object obj, boolean z) {
|
||
|
return tailMap((ImmutableSortedMap<K, V>) obj, z);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap, java.util.SortedMap
|
||
|
public final /* bridge */ /* synthetic */ SortedMap tailMap(Object obj) {
|
||
|
return tailMap((ImmutableSortedMap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final /* bridge */ /* synthetic */ Collection values() {
|
||
|
return values();
|
||
|
}
|
||
|
|
||
|
static <K, V> ImmutableSortedMap<K, V> emptyMap(Comparator<? super K> comparator) {
|
||
|
if (Ordering.natural().equals(comparator)) {
|
||
|
return of();
|
||
|
}
|
||
|
return new ImmutableSortedMap<>(ImmutableSortedSet.emptySet(comparator), ImmutableList.of());
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Incorrect types in method signature: <K::Ljava/lang/Comparable<-TK;>;V:Ljava/lang/Object;>(TK;TV;)Lcom/google/common/collect/ImmutableSortedMap<TK;TV;>; */
|
||
|
public static ImmutableSortedMap of(Comparable comparable, Object obj) {
|
||
|
return of(Ordering.natural(), comparable, obj);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static <K, V> ImmutableSortedMap<K, V> of(Comparator<? super K> comparator, K k, V v) {
|
||
|
return new ImmutableSortedMap<>(new RegularImmutableSortedSet(ImmutableList.of(k), (Comparator) Preconditions.checkNotNull(comparator)), ImmutableList.of(v));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Incorrect types in method signature: <K::Ljava/lang/Comparable<-TK;>;V:Ljava/lang/Object;>(TK;TV;TK;TV;)Lcom/google/common/collect/ImmutableSortedMap<TK;TV;>; */
|
||
|
public static ImmutableSortedMap of(Comparable comparable, Object obj, Comparable comparable2, Object obj2) {
|
||
|
return ofEntries(entryOf(comparable, obj), entryOf(comparable2, obj2));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Incorrect types in method signature: <K::Ljava/lang/Comparable<-TK;>;V:Ljava/lang/Object;>(TK;TV;TK;TV;TK;TV;)Lcom/google/common/collect/ImmutableSortedMap<TK;TV;>; */
|
||
|
public static ImmutableSortedMap of(Comparable comparable, Object obj, Comparable comparable2, Object obj2, Comparable comparable3, Object obj3) {
|
||
|
return ofEntries(entryOf(comparable, obj), entryOf(comparable2, obj2), entryOf(comparable3, obj3));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Incorrect types in method signature: <K::Ljava/lang/Comparable<-TK;>;V:Ljava/lang/Object;>(TK;TV;TK;TV;TK;TV;TK;TV;)Lcom/google/common/collect/ImmutableSortedMap<TK;TV;>; */
|
||
|
public static ImmutableSortedMap of(Comparable comparable, Object obj, Comparable comparable2, Object obj2, Comparable comparable3, Object obj3, Comparable comparable4, Object obj4) {
|
||
|
return ofEntries(entryOf(comparable, obj), entryOf(comparable2, obj2), entryOf(comparable3, obj3), entryOf(comparable4, obj4));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Incorrect types in method signature: <K::Ljava/lang/Comparable<-TK;>;V:Ljava/lang/Object;>(TK;TV;TK;TV;TK;TV;TK;TV;TK;TV;)Lcom/google/common/collect/ImmutableSortedMap<TK;TV;>; */
|
||
|
public static ImmutableSortedMap of(Comparable comparable, Object obj, Comparable comparable2, Object obj2, Comparable comparable3, Object obj3, Comparable comparable4, Object obj4, Comparable comparable5, Object obj5) {
|
||
|
return ofEntries(entryOf(comparable, obj), entryOf(comparable2, obj2), entryOf(comparable3, obj3), entryOf(comparable4, obj4), entryOf(comparable5, obj5));
|
||
|
}
|
||
|
|
||
|
private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V> ofEntries(Map.Entry<K, V>... entryArr) {
|
||
|
return fromEntries(Ordering.natural(), false, entryArr, entryArr.length);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
|
||
|
return copyOfInternal(map, (Ordering) NATURAL_ORDER);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> copyOf(Map<? extends K, ? extends V> map, Comparator<? super K> comparator) {
|
||
|
return copyOfInternal(map, (Comparator) Preconditions.checkNotNull(comparator));
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> copyOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
|
||
|
return copyOf(iterable, (Ordering) NATURAL_ORDER);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> copyOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable, Comparator<? super K> comparator) {
|
||
|
return fromEntries((Comparator) Preconditions.checkNotNull(comparator), false, iterable);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> copyOfSorted(SortedMap<K, ? extends V> sortedMap) {
|
||
|
Comparator<? super K> comparator = sortedMap.comparator();
|
||
|
if (comparator == null) {
|
||
|
comparator = NATURAL_ORDER;
|
||
|
}
|
||
|
if (sortedMap instanceof ImmutableSortedMap) {
|
||
|
ImmutableSortedMap<K, V> immutableSortedMap = (ImmutableSortedMap) sortedMap;
|
||
|
if (!immutableSortedMap.isPartialView()) {
|
||
|
return immutableSortedMap;
|
||
|
}
|
||
|
}
|
||
|
return fromEntries(comparator, true, sortedMap.entrySet());
|
||
|
}
|
||
|
|
||
|
private static <K, V> ImmutableSortedMap<K, V> copyOfInternal(Map<? extends K, ? extends V> map, Comparator<? super K> comparator) {
|
||
|
boolean z = false;
|
||
|
if (map instanceof SortedMap) {
|
||
|
Comparator<? super K> comparator2 = ((SortedMap) map).comparator();
|
||
|
if (comparator2 != null) {
|
||
|
z = comparator.equals(comparator2);
|
||
|
} else if (comparator == NATURAL_ORDER) {
|
||
|
z = true;
|
||
|
}
|
||
|
}
|
||
|
if (z && (map instanceof ImmutableSortedMap)) {
|
||
|
ImmutableSortedMap<K, V> immutableSortedMap = (ImmutableSortedMap) map;
|
||
|
if (!immutableSortedMap.isPartialView()) {
|
||
|
return immutableSortedMap;
|
||
|
}
|
||
|
}
|
||
|
return fromEntries(comparator, z, map.entrySet());
|
||
|
}
|
||
|
|
||
|
private static <K, V> ImmutableSortedMap<K, V> fromEntries(Comparator<? super K> comparator, boolean z, Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
|
||
|
Map.Entry[] entryArr = (Map.Entry[]) Iterables.toArray(iterable, EMPTY_ENTRY_ARRAY);
|
||
|
return fromEntries(comparator, z, entryArr, entryArr.length);
|
||
|
}
|
||
|
|
||
|
private static <K, V> ImmutableSortedMap<K, V> fromEntries(Comparator<? super K> comparator, boolean z, Map.Entry<K, V>[] entryArr, int i) {
|
||
|
if (i == 0) {
|
||
|
return emptyMap(comparator);
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
return of(comparator, entryArr[0].getKey(), entryArr[0].getValue());
|
||
|
}
|
||
|
Object[] objArr = new Object[i];
|
||
|
Object[] objArr2 = new Object[i];
|
||
|
if (z) {
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
K key = entryArr[i2].getKey();
|
||
|
V value = entryArr[i2].getValue();
|
||
|
CollectPreconditions.checkEntryNotNull(key, value);
|
||
|
objArr[i2] = key;
|
||
|
objArr2[i2] = value;
|
||
|
}
|
||
|
} else {
|
||
|
Arrays.sort(entryArr, 0, i, new Comparator<Map.Entry<K, V>>(comparator) { // from class: com.google.common.collect.ImmutableSortedMap.1
|
||
|
final Comparator val$comparator;
|
||
|
|
||
|
{
|
||
|
this.val$comparator = comparator;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Comparator
|
||
|
public int compare(Map.Entry<K, V> entry, Map.Entry<K, V> entry2) {
|
||
|
return this.val$comparator.compare(entry.getKey(), entry2.getKey());
|
||
|
}
|
||
|
});
|
||
|
Object key2 = entryArr[0].getKey();
|
||
|
objArr[0] = key2;
|
||
|
V value2 = entryArr[0].getValue();
|
||
|
objArr2[0] = value2;
|
||
|
CollectPreconditions.checkEntryNotNull(objArr[0], value2);
|
||
|
int i3 = 1;
|
||
|
while (i3 < i) {
|
||
|
Object key3 = entryArr[i3].getKey();
|
||
|
V value3 = entryArr[i3].getValue();
|
||
|
CollectPreconditions.checkEntryNotNull(key3, value3);
|
||
|
objArr[i3] = key3;
|
||
|
objArr2[i3] = value3;
|
||
|
checkNoConflict(comparator.compare(key2, key3) != 0, "key", entryArr[i3 - 1], entryArr[i3]);
|
||
|
i3++;
|
||
|
key2 = key3;
|
||
|
}
|
||
|
}
|
||
|
return new ImmutableSortedMap<>(new RegularImmutableSortedSet(ImmutableList.asImmutableList(objArr), comparator), ImmutableList.asImmutableList(objArr2));
|
||
|
}
|
||
|
|
||
|
public static <K extends Comparable<?>, V> Builder<K, V> naturalOrder() {
|
||
|
return new Builder<>(Ordering.natural());
|
||
|
}
|
||
|
|
||
|
public static <K, V> Builder<K, V> orderedBy(Comparator<K> comparator) {
|
||
|
return new Builder<>(comparator);
|
||
|
}
|
||
|
|
||
|
public static <K extends Comparable<?>, V> Builder<K, V> reverseOrder() {
|
||
|
return new Builder<>(Ordering.natural().reverse());
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class Builder<K, V> extends ImmutableMap.Builder<K, V> {
|
||
|
private final Comparator<? super K> comparator;
|
||
|
private transient Object[] keys;
|
||
|
private transient Object[] values;
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public /* bridge */ /* synthetic */ ImmutableMap.Builder put(Object obj, Object obj2) {
|
||
|
return put((Builder<K, V>) obj, obj2);
|
||
|
}
|
||
|
|
||
|
public Builder(Comparator<? super K> comparator) {
|
||
|
this(comparator, 4);
|
||
|
}
|
||
|
|
||
|
private Builder(Comparator<? super K> comparator, int i) {
|
||
|
this.comparator = (Comparator) Preconditions.checkNotNull(comparator);
|
||
|
this.keys = new Object[i];
|
||
|
this.values = new Object[i];
|
||
|
}
|
||
|
|
||
|
private void ensureCapacity(int i) {
|
||
|
Object[] objArr = this.keys;
|
||
|
if (i > objArr.length) {
|
||
|
int expandedCapacity = ImmutableCollection.Builder.expandedCapacity(objArr.length, i);
|
||
|
this.keys = Arrays.copyOf(this.keys, expandedCapacity);
|
||
|
this.values = Arrays.copyOf(this.values, expandedCapacity);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public Builder<K, V> put(K k, V v) {
|
||
|
ensureCapacity(this.size + 1);
|
||
|
CollectPreconditions.checkEntryNotNull(k, v);
|
||
|
this.keys[this.size] = k;
|
||
|
this.values[this.size] = v;
|
||
|
this.size++;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public Builder<K, V> put(Map.Entry<? extends K, ? extends V> entry) {
|
||
|
super.put((Map.Entry) entry);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
|
||
|
super.putAll((Map) map);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public Builder<K, V> putAll(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
|
||
|
super.putAll((Iterable) iterable);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
@Deprecated
|
||
|
public final Builder<K, V> orderEntriesByValue(Comparator<? super V> comparator) {
|
||
|
throw new UnsupportedOperationException("Not available on ImmutableSortedMap.Builder");
|
||
|
}
|
||
|
|
||
|
Builder<K, V> combine(Builder<K, V> builder) {
|
||
|
ensureCapacity(this.size + builder.size);
|
||
|
System.arraycopy(builder.keys, 0, this.keys, this.size, builder.size);
|
||
|
System.arraycopy(builder.values, 0, this.values, this.size, builder.size);
|
||
|
this.size += builder.size;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public ImmutableSortedMap<K, V> build() {
|
||
|
int i = this.size;
|
||
|
if (i == 0) {
|
||
|
return ImmutableSortedMap.emptyMap(this.comparator);
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
return ImmutableSortedMap.of(this.comparator, this.keys[0], this.values[0]);
|
||
|
}
|
||
|
Object[] copyOf = Arrays.copyOf(this.keys, this.size);
|
||
|
Arrays.sort(copyOf, this.comparator);
|
||
|
Object[] objArr = new Object[this.size];
|
||
|
for (int i2 = 0; i2 < this.size; i2++) {
|
||
|
if (i2 > 0) {
|
||
|
int i3 = i2 - 1;
|
||
|
if (this.comparator.compare(copyOf[i3], copyOf[i2]) == 0) {
|
||
|
String valueOf = String.valueOf(copyOf[i3]);
|
||
|
String valueOf2 = String.valueOf(copyOf[i2]);
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 57 + String.valueOf(valueOf2).length());
|
||
|
sb.append("keys required to be distinct but compared as equal: ");
|
||
|
sb.append(valueOf);
|
||
|
sb.append(" and ");
|
||
|
sb.append(valueOf2);
|
||
|
throw new IllegalArgumentException(sb.toString());
|
||
|
}
|
||
|
}
|
||
|
objArr[Arrays.binarySearch(copyOf, this.keys[i2], this.comparator)] = this.values[i2];
|
||
|
}
|
||
|
return new ImmutableSortedMap<>(new RegularImmutableSortedSet(ImmutableList.asImmutableList(copyOf), this.comparator), ImmutableList.asImmutableList(objArr));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public ImmutableSortedMap(RegularImmutableSortedSet<K> regularImmutableSortedSet, ImmutableList<V> immutableList) {
|
||
|
this(regularImmutableSortedSet, immutableList, null);
|
||
|
}
|
||
|
|
||
|
ImmutableSortedMap(RegularImmutableSortedSet<K> regularImmutableSortedSet, ImmutableList<V> immutableList, ImmutableSortedMap<K, V> immutableSortedMap) {
|
||
|
this.keySet = regularImmutableSortedSet;
|
||
|
this.valueList = immutableList;
|
||
|
this.descendingMap = immutableSortedMap;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Map
|
||
|
public final int size() {
|
||
|
return this.valueList.size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final V get(Object obj) {
|
||
|
int indexOf = this.keySet.indexOf(obj);
|
||
|
if (indexOf == -1) {
|
||
|
return null;
|
||
|
}
|
||
|
return this.valueList.get(indexOf);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.ImmutableMap
|
||
|
public final boolean isPartialView() {
|
||
|
return this.keySet.isPartialView() || this.valueList.isPartialView();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final ImmutableSet<Map.Entry<K, V>> entrySet() {
|
||
|
return super.entrySet();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.google.common.collect.ImmutableSortedMap$1EntrySet, reason: invalid class name */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class C1EntrySet extends ImmutableMapEntrySet<K, V> {
|
||
|
final ImmutableSortedMap this$0;
|
||
|
|
||
|
C1EntrySet(ImmutableSortedMap immutableSortedMap) {
|
||
|
this.this$0 = immutableSortedMap;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
|
||
|
public /* bridge */ /* synthetic */ Iterator iterator() {
|
||
|
return iterator();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
|
||
|
public UnmodifiableIterator<Map.Entry<K, V>> iterator() {
|
||
|
return asList().iterator();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.ImmutableSet
|
||
|
public ImmutableList<Map.Entry<K, V>> createAsList() {
|
||
|
return new ImmutableList<Map.Entry<K, V>>(this) { // from class: com.google.common.collect.ImmutableSortedMap.1EntrySet.1
|
||
|
final C1EntrySet this$1;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.ImmutableCollection
|
||
|
public boolean isPartialView() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.this$1 = this;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.List
|
||
|
public Map.Entry<K, V> get(int i) {
|
||
|
return new AbstractMap.SimpleImmutableEntry(this.this$1.this$0.keySet.asList().get(i), this.this$1.this$0.valueList.get(i));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||
|
public int size() {
|
||
|
return this.this$1.this$0.size();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMapEntrySet
|
||
|
ImmutableMap<K, V> map() {
|
||
|
return this.this$0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap
|
||
|
final ImmutableSet<Map.Entry<K, V>> createEntrySet() {
|
||
|
return isEmpty() ? ImmutableSet.of() : new C1EntrySet(this);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap
|
||
|
final ImmutableSet<K> createKeySet() {
|
||
|
throw new AssertionError("should never be called");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap
|
||
|
final ImmutableCollection<V> createValues() {
|
||
|
throw new AssertionError("should never be called");
|
||
|
}
|
||
|
|
||
|
@Override // java.util.SortedMap
|
||
|
public final Comparator<? super K> comparator() {
|
||
|
return keySet().comparator();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.SortedMap
|
||
|
public final K firstKey() {
|
||
|
return keySet().first();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.SortedMap
|
||
|
public final K lastKey() {
|
||
|
return keySet().last();
|
||
|
}
|
||
|
|
||
|
private ImmutableSortedMap<K, V> getSubMap(int i, int i2) {
|
||
|
if (i == 0 && i2 == size()) {
|
||
|
return this;
|
||
|
}
|
||
|
if (i == i2) {
|
||
|
return emptyMap(comparator());
|
||
|
}
|
||
|
return new ImmutableSortedMap<>(this.keySet.getSubSet(i, i2), this.valueList.subList(i, i2));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap, java.util.SortedMap
|
||
|
public final ImmutableSortedMap<K, V> headMap(K k) {
|
||
|
return headMap((ImmutableSortedMap<K, V>) k, false);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedMap<K, V> headMap(K k, boolean z) {
|
||
|
return getSubMap(0, this.keySet.headIndex(Preconditions.checkNotNull(k), z));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap, java.util.SortedMap
|
||
|
public final ImmutableSortedMap<K, V> subMap(K k, K k2) {
|
||
|
return subMap((boolean) k, true, (boolean) k2, false);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedMap<K, V> subMap(K k, boolean z, K k2, boolean z2) {
|
||
|
Preconditions.checkNotNull(k);
|
||
|
Preconditions.checkNotNull(k2);
|
||
|
Preconditions.checkArgument(comparator().compare(k, k2) <= 0, "expected fromKey <= toKey but %s > %s", k, k2);
|
||
|
return headMap((ImmutableSortedMap<K, V>) k2, z2).tailMap((ImmutableSortedMap<K, V>) k, z);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap, java.util.SortedMap
|
||
|
public final ImmutableSortedMap<K, V> tailMap(K k) {
|
||
|
return tailMap((ImmutableSortedMap<K, V>) k, true);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedMap<K, V> tailMap(K k, boolean z) {
|
||
|
return getSubMap(this.keySet.tailIndex(Preconditions.checkNotNull(k), z), size());
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> lowerEntry(K k) {
|
||
|
return headMap((ImmutableSortedMap<K, V>) k, false).lastEntry();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final K lowerKey(K k) {
|
||
|
return (K) Maps.keyOrNull(lowerEntry(k));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> floorEntry(K k) {
|
||
|
return headMap((ImmutableSortedMap<K, V>) k, true).lastEntry();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final K floorKey(K k) {
|
||
|
return (K) Maps.keyOrNull(floorEntry(k));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> ceilingEntry(K k) {
|
||
|
return tailMap((ImmutableSortedMap<K, V>) k, true).firstEntry();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final K ceilingKey(K k) {
|
||
|
return (K) Maps.keyOrNull(ceilingEntry(k));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> higherEntry(K k) {
|
||
|
return tailMap((ImmutableSortedMap<K, V>) k, false).firstEntry();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final K higherKey(K k) {
|
||
|
return (K) Maps.keyOrNull(higherEntry(k));
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> firstEntry() {
|
||
|
if (isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return entrySet().asList().get(0);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final Map.Entry<K, V> lastEntry() {
|
||
|
if (isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return entrySet().asList().get(size() - 1);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
@Deprecated
|
||
|
public final Map.Entry<K, V> pollFirstEntry() {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
@Deprecated
|
||
|
public final Map.Entry<K, V> pollLastEntry() {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedMap<K, V> descendingMap() {
|
||
|
ImmutableSortedMap<K, V> immutableSortedMap = this.descendingMap;
|
||
|
if (immutableSortedMap != null) {
|
||
|
return immutableSortedMap;
|
||
|
}
|
||
|
if (isEmpty()) {
|
||
|
return emptyMap(Ordering.from(comparator()).reverse());
|
||
|
}
|
||
|
return new ImmutableSortedMap<>((RegularImmutableSortedSet) this.keySet.descendingSet(), this.valueList.reverse(), this);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedSet<K> descendingKeySet() {
|
||
|
return this.keySet.descendingSet();
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class SerializedForm<K, V> extends ImmutableMap.SerializedForm<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
private final Comparator<? super K> comparator;
|
||
|
|
||
|
SerializedForm(ImmutableSortedMap<K, V> immutableSortedMap) {
|
||
|
super(immutableSortedMap);
|
||
|
this.comparator = immutableSortedMap.comparator();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.ImmutableMap.SerializedForm
|
||
|
public Builder<K, V> makeBuilder(int i) {
|
||
|
return new Builder<>(this.comparator);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap
|
||
|
final Object writeReplace() {
|
||
|
return new SerializedForm(this);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final ImmutableCollection<V> values() {
|
||
|
return this.valueList;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.NavigableMap
|
||
|
public final ImmutableSortedSet<K> navigableKeySet() {
|
||
|
return this.keySet;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
||
|
public final ImmutableSortedSet<K> keySet() {
|
||
|
return this.keySet;
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableSortedMap<K, V> of() {
|
||
|
return (ImmutableSortedMap<K, V>) NATURAL_EMPTY_MAP;
|
||
|
}
|
||
|
}
|