mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
700 lines
28 KiB
Java
700 lines
28 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.ImmutableCollection;
|
|
import com.google.errorprone.annotations.DoNotMock;
|
|
import com.google.errorprone.annotations.concurrent.LazyInit;
|
|
import java.io.Serializable;
|
|
import java.util.AbstractMap;
|
|
import java.util.Arrays;
|
|
import java.util.BitSet;
|
|
import java.util.Collection;
|
|
import java.util.Comparator;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.SortedMap;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@DoNotMock("Use ImmutableMap.of or another implementation")
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
|
|
static final Map.Entry<?, ?>[] EMPTY_ENTRY_ARRAY = new Map.Entry[0];
|
|
|
|
@CheckForNull
|
|
@LazyInit
|
|
private transient ImmutableSet<Map.Entry<K, V>> entrySet;
|
|
|
|
@CheckForNull
|
|
@LazyInit
|
|
private transient ImmutableSet<K> keySet;
|
|
|
|
@CheckForNull
|
|
@LazyInit
|
|
private transient ImmutableSetMultimap<K, V> multimapView;
|
|
|
|
@CheckForNull
|
|
@LazyInit
|
|
private transient ImmutableCollection<V> values;
|
|
|
|
abstract ImmutableSet<Map.Entry<K, V>> createEntrySet();
|
|
|
|
abstract ImmutableSet<K> createKeySet();
|
|
|
|
abstract ImmutableCollection<V> createValues();
|
|
|
|
@Override // java.util.Map
|
|
@CheckForNull
|
|
public abstract V get(@CheckForNull Object obj);
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public boolean isHashCodeFast() {
|
|
return false;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public abstract boolean isPartialView();
|
|
|
|
public static <K, V> ImmutableMap<K, V> of() {
|
|
return (ImmutableMap<K, V>) RegularImmutableMap.EMPTY;
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
return RegularImmutableMap.create(1, new Object[]{k, v});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
return RegularImmutableMap.create(2, new Object[]{k, v, k2, v2});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
return RegularImmutableMap.create(3, new Object[]{k, v, k2, v2, k3, v3});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
return RegularImmutableMap.create(4, new Object[]{k, v, k2, v2, k3, v3, k4, v4});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
return RegularImmutableMap.create(5, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
CollectPreconditions.checkEntryNotNull(k6, v6);
|
|
return RegularImmutableMap.create(6, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
CollectPreconditions.checkEntryNotNull(k6, v6);
|
|
CollectPreconditions.checkEntryNotNull(k7, v7);
|
|
return RegularImmutableMap.create(7, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
CollectPreconditions.checkEntryNotNull(k6, v6);
|
|
CollectPreconditions.checkEntryNotNull(k7, v7);
|
|
CollectPreconditions.checkEntryNotNull(k8, v8);
|
|
return RegularImmutableMap.create(8, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
CollectPreconditions.checkEntryNotNull(k6, v6);
|
|
CollectPreconditions.checkEntryNotNull(k7, v7);
|
|
CollectPreconditions.checkEntryNotNull(k8, v8);
|
|
CollectPreconditions.checkEntryNotNull(k9, v9);
|
|
return RegularImmutableMap.create(9, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9});
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
CollectPreconditions.checkEntryNotNull(k2, v2);
|
|
CollectPreconditions.checkEntryNotNull(k3, v3);
|
|
CollectPreconditions.checkEntryNotNull(k4, v4);
|
|
CollectPreconditions.checkEntryNotNull(k5, v5);
|
|
CollectPreconditions.checkEntryNotNull(k6, v6);
|
|
CollectPreconditions.checkEntryNotNull(k7, v7);
|
|
CollectPreconditions.checkEntryNotNull(k8, v8);
|
|
CollectPreconditions.checkEntryNotNull(k9, v9);
|
|
CollectPreconditions.checkEntryNotNull(k10, v10);
|
|
return RegularImmutableMap.create(10, new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10});
|
|
}
|
|
|
|
@SafeVarargs
|
|
public static <K, V> ImmutableMap<K, V> ofEntries(Map.Entry<? extends K, ? extends V>... entryArr) {
|
|
return copyOf(Arrays.asList(entryArr));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static <K, V> Map.Entry<K, V> entryOf(K k, V v) {
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
return new AbstractMap.SimpleImmutableEntry(k, v);
|
|
}
|
|
|
|
public static <K, V> Builder<K, V> builder() {
|
|
return new Builder<>();
|
|
}
|
|
|
|
public static <K, V> Builder<K, V> builderWithExpectedSize(int i) {
|
|
CollectPreconditions.checkNonnegative(i, "expectedSize");
|
|
return new Builder<>(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static void checkNoConflict(boolean z, String str, Object obj, Object obj2) {
|
|
if (!z) {
|
|
throw conflictException(str, obj, obj2);
|
|
}
|
|
}
|
|
|
|
static IllegalArgumentException conflictException(String str, Object obj, Object obj2) {
|
|
String valueOf = String.valueOf(obj);
|
|
String valueOf2 = String.valueOf(obj2);
|
|
return new IllegalArgumentException(new StringBuilder(String.valueOf(str).length() + 34 + String.valueOf(valueOf).length() + String.valueOf(valueOf2).length()).append("Multiple entries with same ").append(str).append(": ").append(valueOf).append(" and ").append(valueOf2).toString());
|
|
}
|
|
|
|
@DoNotMock
|
|
/* loaded from: classes3.dex */
|
|
public static class Builder<K, V> {
|
|
Object[] alternatingKeysAndValues;
|
|
DuplicateKey duplicateKey;
|
|
boolean entriesUsed;
|
|
int size;
|
|
|
|
@CheckForNull
|
|
Comparator<? super V> valueComparator;
|
|
|
|
public Builder() {
|
|
this(4);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public Builder(int i) {
|
|
this.alternatingKeysAndValues = new Object[i * 2];
|
|
this.size = 0;
|
|
this.entriesUsed = false;
|
|
}
|
|
|
|
private void ensureCapacity(int i) {
|
|
int i2 = i * 2;
|
|
Object[] objArr = this.alternatingKeysAndValues;
|
|
if (i2 > objArr.length) {
|
|
this.alternatingKeysAndValues = Arrays.copyOf(objArr, ImmutableCollection.Builder.expandedCapacity(objArr.length, i2));
|
|
this.entriesUsed = false;
|
|
}
|
|
}
|
|
|
|
public Builder<K, V> put(K k, V v) {
|
|
ensureCapacity(this.size + 1);
|
|
CollectPreconditions.checkEntryNotNull(k, v);
|
|
Object[] objArr = this.alternatingKeysAndValues;
|
|
int i = this.size;
|
|
objArr[i * 2] = k;
|
|
objArr[(i * 2) + 1] = v;
|
|
this.size = i + 1;
|
|
return this;
|
|
}
|
|
|
|
public Builder<K, V> put(Map.Entry<? extends K, ? extends V> entry) {
|
|
return put(entry.getKey(), entry.getValue());
|
|
}
|
|
|
|
public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
|
|
return putAll(map.entrySet());
|
|
}
|
|
|
|
public Builder<K, V> putAll(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
|
|
if (iterable instanceof Collection) {
|
|
ensureCapacity(this.size + ((Collection) iterable).size());
|
|
}
|
|
Iterator<? extends Map.Entry<? extends K, ? extends V>> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
put(it.next());
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public Builder<K, V> orderEntriesByValue(Comparator<? super V> comparator) {
|
|
Preconditions.checkState(this.valueComparator == null, "valueComparator was already set");
|
|
this.valueComparator = (Comparator) Preconditions.checkNotNull(comparator, "valueComparator");
|
|
return this;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public Builder<K, V> combine(Builder<K, V> builder) {
|
|
Preconditions.checkNotNull(builder);
|
|
ensureCapacity(this.size + builder.size);
|
|
System.arraycopy(builder.alternatingKeysAndValues, 0, this.alternatingKeysAndValues, this.size * 2, builder.size * 2);
|
|
this.size += builder.size;
|
|
return this;
|
|
}
|
|
|
|
private ImmutableMap<K, V> build(boolean z) {
|
|
Object[] objArr;
|
|
DuplicateKey duplicateKey;
|
|
DuplicateKey duplicateKey2;
|
|
if (z && (duplicateKey2 = this.duplicateKey) != null) {
|
|
throw duplicateKey2.exception();
|
|
}
|
|
int i = this.size;
|
|
if (this.valueComparator == null) {
|
|
objArr = this.alternatingKeysAndValues;
|
|
} else {
|
|
if (this.entriesUsed) {
|
|
this.alternatingKeysAndValues = Arrays.copyOf(this.alternatingKeysAndValues, i * 2);
|
|
}
|
|
objArr = this.alternatingKeysAndValues;
|
|
if (!z) {
|
|
objArr = lastEntryForEachKey(objArr, this.size);
|
|
if (objArr.length < this.alternatingKeysAndValues.length) {
|
|
i = objArr.length >>> 1;
|
|
}
|
|
}
|
|
sortEntries(objArr, i, this.valueComparator);
|
|
}
|
|
this.entriesUsed = true;
|
|
RegularImmutableMap create = RegularImmutableMap.create(i, objArr, this);
|
|
if (!z || (duplicateKey = this.duplicateKey) == null) {
|
|
return create;
|
|
}
|
|
throw duplicateKey.exception();
|
|
}
|
|
|
|
public ImmutableMap<K, V> build() {
|
|
return buildOrThrow();
|
|
}
|
|
|
|
public ImmutableMap<K, V> buildOrThrow() {
|
|
return build(true);
|
|
}
|
|
|
|
public ImmutableMap<K, V> buildKeepingLast() {
|
|
return build(false);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static <V> void sortEntries(Object[] objArr, int i, Comparator<? super V> comparator) {
|
|
Map.Entry[] entryArr = new Map.Entry[i];
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
int i3 = i2 * 2;
|
|
entryArr[i2] = new AbstractMap.SimpleImmutableEntry(Objects.requireNonNull(objArr[i3]), Objects.requireNonNull(objArr[i3 + 1]));
|
|
}
|
|
Arrays.sort(entryArr, 0, i, Ordering.from(comparator).onResultOf(Maps.valueFunction()));
|
|
for (int i4 = 0; i4 < i; i4++) {
|
|
int i5 = i4 * 2;
|
|
objArr[i5] = entryArr[i4].getKey();
|
|
objArr[i5 + 1] = entryArr[i4].getValue();
|
|
}
|
|
}
|
|
|
|
private Object[] lastEntryForEachKey(Object[] objArr, int i) {
|
|
HashSet hashSet = new HashSet();
|
|
BitSet bitSet = new BitSet();
|
|
for (int i2 = i - 1; i2 >= 0; i2--) {
|
|
if (!hashSet.add(Objects.requireNonNull(objArr[i2 * 2]))) {
|
|
bitSet.set(i2);
|
|
}
|
|
}
|
|
if (bitSet.isEmpty()) {
|
|
return objArr;
|
|
}
|
|
Object[] objArr2 = new Object[(i - bitSet.cardinality()) * 2];
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
while (i3 < i * 2) {
|
|
if (bitSet.get(i3 >>> 1)) {
|
|
i3 += 2;
|
|
} else {
|
|
int i5 = i4 + 1;
|
|
int i6 = i3 + 1;
|
|
objArr2[i4] = Objects.requireNonNull(objArr[i3]);
|
|
i4 += 2;
|
|
i3 += 2;
|
|
objArr2[i5] = Objects.requireNonNull(objArr[i6]);
|
|
}
|
|
}
|
|
return objArr2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public static final class DuplicateKey {
|
|
private final Object key;
|
|
private final Object value1;
|
|
private final Object value2;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public DuplicateKey(Object obj, Object obj2, Object obj3) {
|
|
this.key = obj;
|
|
this.value1 = obj2;
|
|
this.value2 = obj3;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public IllegalArgumentException exception() {
|
|
String valueOf = String.valueOf(this.key);
|
|
String valueOf2 = String.valueOf(this.value1);
|
|
String valueOf3 = String.valueOf(this.key);
|
|
String valueOf4 = String.valueOf(this.value2);
|
|
return new IllegalArgumentException(new StringBuilder(String.valueOf(valueOf).length() + 39 + String.valueOf(valueOf2).length() + String.valueOf(valueOf3).length() + String.valueOf(valueOf4).length()).append("Multiple entries with same key: ").append(valueOf).append("=").append(valueOf2).append(" and ").append(valueOf3).append("=").append(valueOf4).toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
|
|
if ((map instanceof ImmutableMap) && !(map instanceof SortedMap)) {
|
|
ImmutableMap<K, V> immutableMap = (ImmutableMap) map;
|
|
if (!immutableMap.isPartialView()) {
|
|
return immutableMap;
|
|
}
|
|
}
|
|
return copyOf(map.entrySet());
|
|
}
|
|
|
|
public static <K, V> ImmutableMap<K, V> copyOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
|
|
Builder builder = new Builder(iterable instanceof Collection ? ((Collection) iterable).size() : 4);
|
|
builder.putAll(iterable);
|
|
return builder.build();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public static abstract class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
|
|
abstract UnmodifiableIterator<Map.Entry<K, V>> entryIterator();
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
|
public /* bridge */ /* synthetic */ Set entrySet() {
|
|
return super.entrySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
|
public /* bridge */ /* synthetic */ Set keySet() {
|
|
return super.keySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map, com.google.common.collect.BiMap
|
|
public /* bridge */ /* synthetic */ Collection values() {
|
|
return super.values();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ImmutableMap
|
|
public ImmutableSet<K> createKeySet() {
|
|
return new ImmutableMapKeySet(this);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap
|
|
ImmutableSet<Map.Entry<K, V>> createEntrySet() {
|
|
return new ImmutableMapEntrySet<K, V>() { // from class: com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap.1EntrySetImpl
|
|
@Override // com.google.common.collect.ImmutableMapEntrySet
|
|
ImmutableMap<K, V> map() {
|
|
return IteratorBasedImmutableMap.this;
|
|
}
|
|
|
|
@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 IteratorBasedImmutableMap.this.entryIterator();
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap
|
|
ImmutableCollection<V> createValues() {
|
|
return new ImmutableMapValues(this);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
@CheckForNull
|
|
@Deprecated
|
|
public final V put(K k, V v) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
@CheckForNull
|
|
@Deprecated
|
|
public final V remove(@CheckForNull Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
@Deprecated
|
|
public final void putAll(Map<? extends K, ? extends V> map) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
@Deprecated
|
|
public final void clear() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public boolean isEmpty() {
|
|
return size() == 0;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public boolean containsKey(@CheckForNull Object obj) {
|
|
return get(obj) != null;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public boolean containsValue(@CheckForNull Object obj) {
|
|
return values().contains(obj);
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
@CheckForNull
|
|
public final V getOrDefault(@CheckForNull Object obj, @CheckForNull V v) {
|
|
V v2 = get(obj);
|
|
return v2 != null ? v2 : v;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public ImmutableSet<Map.Entry<K, V>> entrySet() {
|
|
ImmutableSet<Map.Entry<K, V>> immutableSet = this.entrySet;
|
|
if (immutableSet != null) {
|
|
return immutableSet;
|
|
}
|
|
ImmutableSet<Map.Entry<K, V>> createEntrySet = createEntrySet();
|
|
this.entrySet = createEntrySet;
|
|
return createEntrySet;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public ImmutableSet<K> keySet() {
|
|
ImmutableSet<K> immutableSet = this.keySet;
|
|
if (immutableSet != null) {
|
|
return immutableSet;
|
|
}
|
|
ImmutableSet<K> createKeySet = createKeySet();
|
|
this.keySet = createKeySet;
|
|
return createKeySet;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public UnmodifiableIterator<K> keyIterator() {
|
|
final UnmodifiableIterator<Map.Entry<K, V>> it = entrySet().iterator();
|
|
return new UnmodifiableIterator<K>(this) { // from class: com.google.common.collect.ImmutableMap.1
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return it.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public K next() {
|
|
return (K) ((Map.Entry) it.next()).getKey();
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // java.util.Map, com.google.common.collect.BiMap
|
|
public ImmutableCollection<V> values() {
|
|
ImmutableCollection<V> immutableCollection = this.values;
|
|
if (immutableCollection != null) {
|
|
return immutableCollection;
|
|
}
|
|
ImmutableCollection<V> createValues = createValues();
|
|
this.values = createValues;
|
|
return createValues;
|
|
}
|
|
|
|
public ImmutableSetMultimap<K, V> asMultimap() {
|
|
if (isEmpty()) {
|
|
return ImmutableSetMultimap.of();
|
|
}
|
|
ImmutableSetMultimap<K, V> immutableSetMultimap = this.multimapView;
|
|
if (immutableSetMultimap != null) {
|
|
return immutableSetMultimap;
|
|
}
|
|
ImmutableSetMultimap<K, V> immutableSetMultimap2 = new ImmutableSetMultimap<>(new MapViewOfValuesAsSingletonSets(), size(), null);
|
|
this.multimapView = immutableSetMultimap2;
|
|
return immutableSetMultimap2;
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private final class MapViewOfValuesAsSingletonSets extends IteratorBasedImmutableMap<K, ImmutableSet<V>> {
|
|
private MapViewOfValuesAsSingletonSets() {
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public int size() {
|
|
return ImmutableMap.this.size();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap, com.google.common.collect.ImmutableMap
|
|
public ImmutableSet<K> createKeySet() {
|
|
return ImmutableMap.this.keySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
|
public boolean containsKey(@CheckForNull Object obj) {
|
|
return ImmutableMap.this.containsKey(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
|
@CheckForNull
|
|
public ImmutableSet<V> get(@CheckForNull Object obj) {
|
|
Object obj2 = ImmutableMap.this.get(obj);
|
|
if (obj2 == null) {
|
|
return null;
|
|
}
|
|
return ImmutableSet.of(obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap
|
|
boolean isPartialView() {
|
|
return ImmutableMap.this.isPartialView();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap, java.util.Map
|
|
public int hashCode() {
|
|
return ImmutableMap.this.hashCode();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap
|
|
boolean isHashCodeFast() {
|
|
return ImmutableMap.this.isHashCodeFast();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap
|
|
UnmodifiableIterator<Map.Entry<K, ImmutableSet<V>>> entryIterator() {
|
|
final UnmodifiableIterator<Map.Entry<K, V>> it = ImmutableMap.this.entrySet().iterator();
|
|
return new UnmodifiableIterator<Map.Entry<K, ImmutableSet<V>>>(this) { // from class: com.google.common.collect.ImmutableMap.MapViewOfValuesAsSingletonSets.1
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return it.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Map.Entry<K, ImmutableSet<V>> next() {
|
|
final Map.Entry entry = (Map.Entry) it.next();
|
|
return new AbstractMapEntry<K, ImmutableSet<V>>(this) { // from class: com.google.common.collect.ImmutableMap.MapViewOfValuesAsSingletonSets.1.1
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
public K getKey() {
|
|
return (K) entry.getKey();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
public ImmutableSet<V> getValue() {
|
|
return ImmutableSet.of(entry.getValue());
|
|
}
|
|
};
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public boolean equals(@CheckForNull Object obj) {
|
|
return Maps.equalsImpl(this, obj);
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public int hashCode() {
|
|
return Sets.hashCodeImpl(entrySet());
|
|
}
|
|
|
|
public String toString() {
|
|
return Maps.toStringImpl(this);
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
static class SerializedForm<K, V> implements Serializable {
|
|
private static final boolean USE_LEGACY_SERIALIZATION = true;
|
|
private static final long serialVersionUID = 0;
|
|
private final Object keys;
|
|
private final Object values;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public SerializedForm(ImmutableMap<K, V> immutableMap) {
|
|
Object[] objArr = new Object[immutableMap.size()];
|
|
Object[] objArr2 = new Object[immutableMap.size()];
|
|
UnmodifiableIterator<Map.Entry<K, V>> it = immutableMap.entrySet().iterator();
|
|
int i = 0;
|
|
while (it.hasNext()) {
|
|
Map.Entry<K, V> next = it.next();
|
|
objArr[i] = next.getKey();
|
|
objArr2[i] = next.getValue();
|
|
i++;
|
|
}
|
|
this.keys = objArr;
|
|
this.values = objArr2;
|
|
}
|
|
|
|
final Object readResolve() {
|
|
Object obj = this.keys;
|
|
if (!(obj instanceof ImmutableSet)) {
|
|
return legacyReadResolve();
|
|
}
|
|
ImmutableSet immutableSet = (ImmutableSet) obj;
|
|
ImmutableCollection immutableCollection = (ImmutableCollection) this.values;
|
|
Builder<K, V> makeBuilder = makeBuilder(immutableSet.size());
|
|
UnmodifiableIterator it = immutableSet.iterator();
|
|
UnmodifiableIterator it2 = immutableCollection.iterator();
|
|
while (it.hasNext()) {
|
|
makeBuilder.put(it.next(), it2.next());
|
|
}
|
|
return makeBuilder.buildOrThrow();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
final Object legacyReadResolve() {
|
|
Object[] objArr = (Object[]) this.keys;
|
|
Object[] objArr2 = (Object[]) this.values;
|
|
Builder<K, V> makeBuilder = makeBuilder(objArr.length);
|
|
for (int i = 0; i < objArr.length; i++) {
|
|
makeBuilder.put(objArr[i], objArr2[i]);
|
|
}
|
|
return makeBuilder.buildOrThrow();
|
|
}
|
|
|
|
Builder<K, V> makeBuilder(int i) {
|
|
return new Builder<>(i);
|
|
}
|
|
}
|
|
|
|
Object writeReplace() {
|
|
return new SerializedForm(this);
|
|
}
|
|
}
|