package com.google.common.collect; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableCollection; import com.google.errorprone.annotations.concurrent.LazyInit; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Arrays; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public final class HashBiMap extends AbstractMap implements BiMap, Serializable { private static final int ABSENT = -1; private static final int ENDPOINT = -2; private transient Set> entrySet; private transient int firstInInsertionOrder; private transient int[] hashTableKToV; private transient int[] hashTableVToK; @CheckForNull @LazyInit private transient BiMap inverse; private transient Set keySet; transient K[] keys; private transient int lastInInsertionOrder; transient int modCount; private transient int[] nextInBucketKToV; private transient int[] nextInBucketVToK; private transient int[] nextInInsertionOrder; private transient int[] prevInInsertionOrder; transient int size; private transient Set valueSet; transient V[] values; @Override // java.util.AbstractMap, java.util.Map public int size() { return this.size; } public static HashBiMap create() { return create(16); } public static HashBiMap create(int i) { return new HashBiMap<>(i); } public static HashBiMap create(Map map) { HashBiMap create = create(map.size()); create.putAll(map); return create; } private HashBiMap(int i) { init(i); } void init(int i) { CollectPreconditions.checkNonnegative(i, "expectedSize"); int closedTableSize = Hashing.closedTableSize(i, 1.0d); this.size = 0; this.keys = (K[]) new Object[i]; this.values = (V[]) new Object[i]; this.hashTableKToV = createFilledWithAbsent(closedTableSize); this.hashTableVToK = createFilledWithAbsent(closedTableSize); this.nextInBucketKToV = createFilledWithAbsent(i); this.nextInBucketVToK = createFilledWithAbsent(i); this.firstInInsertionOrder = -2; this.lastInInsertionOrder = -2; this.prevInInsertionOrder = createFilledWithAbsent(i); this.nextInInsertionOrder = createFilledWithAbsent(i); } private static int[] createFilledWithAbsent(int i) { int[] iArr = new int[i]; Arrays.fill(iArr, -1); return iArr; } private static int[] expandAndFillWithAbsent(int[] iArr, int i) { int length = iArr.length; int[] copyOf = Arrays.copyOf(iArr, i); Arrays.fill(copyOf, length, i, -1); return copyOf; } private void ensureCapacity(int i) { int[] iArr = this.nextInBucketKToV; if (iArr.length < i) { int expandedCapacity = ImmutableCollection.Builder.expandedCapacity(iArr.length, i); this.keys = (K[]) Arrays.copyOf(this.keys, expandedCapacity); this.values = (V[]) Arrays.copyOf(this.values, expandedCapacity); this.nextInBucketKToV = expandAndFillWithAbsent(this.nextInBucketKToV, expandedCapacity); this.nextInBucketVToK = expandAndFillWithAbsent(this.nextInBucketVToK, expandedCapacity); this.prevInInsertionOrder = expandAndFillWithAbsent(this.prevInInsertionOrder, expandedCapacity); this.nextInInsertionOrder = expandAndFillWithAbsent(this.nextInInsertionOrder, expandedCapacity); } if (this.hashTableKToV.length < i) { int closedTableSize = Hashing.closedTableSize(i, 1.0d); this.hashTableKToV = createFilledWithAbsent(closedTableSize); this.hashTableVToK = createFilledWithAbsent(closedTableSize); for (int i2 = 0; i2 < this.size; i2++) { int bucket = bucket(Hashing.smearedHash(this.keys[i2])); int[] iArr2 = this.nextInBucketKToV; int[] iArr3 = this.hashTableKToV; iArr2[i2] = iArr3[bucket]; iArr3[bucket] = i2; int bucket2 = bucket(Hashing.smearedHash(this.values[i2])); int[] iArr4 = this.nextInBucketVToK; int[] iArr5 = this.hashTableVToK; iArr4[i2] = iArr5[bucket2]; iArr5[bucket2] = i2; } } } private int bucket(int i) { return (this.hashTableKToV.length - 1) & i; } int findEntryByKey(@CheckForNull Object obj) { return findEntryByKey(obj, Hashing.smearedHash(obj)); } int findEntryByKey(@CheckForNull Object obj, int i) { return findEntry(obj, i, this.hashTableKToV, this.nextInBucketKToV, this.keys); } int findEntryByValue(@CheckForNull Object obj) { return findEntryByValue(obj, Hashing.smearedHash(obj)); } int findEntryByValue(@CheckForNull Object obj, int i) { return findEntry(obj, i, this.hashTableVToK, this.nextInBucketVToK, this.values); } int findEntry(@CheckForNull Object obj, int i, int[] iArr, int[] iArr2, Object[] objArr) { int i2 = iArr[bucket(i)]; while (i2 != -1) { if (Objects.equal(objArr[i2], obj)) { return i2; } i2 = iArr2[i2]; } return -1; } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return findEntryByKey(obj) != -1; } @Override // java.util.AbstractMap, java.util.Map public boolean containsValue(@CheckForNull Object obj) { return findEntryByValue(obj) != -1; } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V get(@CheckForNull Object obj) { int findEntryByKey = findEntryByKey(obj); if (findEntryByKey == -1) { return null; } return this.values[findEntryByKey]; } @CheckForNull K getInverse(@CheckForNull Object obj) { int findEntryByValue = findEntryByValue(obj); if (findEntryByValue == -1) { return null; } return this.keys[findEntryByValue]; } @Override // java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap @CheckForNull public V put(@ParametricNullness K k, @ParametricNullness V v) { return put(k, v, false); } @CheckForNull V put(@ParametricNullness K k, @ParametricNullness V v, boolean z) { int smearedHash = Hashing.smearedHash(k); int findEntryByKey = findEntryByKey(k, smearedHash); if (findEntryByKey != -1) { V v2 = this.values[findEntryByKey]; if (Objects.equal(v2, v)) { return v; } replaceValueInEntry(findEntryByKey, v, z); return v2; } int smearedHash2 = Hashing.smearedHash(v); int findEntryByValue = findEntryByValue(v, smearedHash2); if (!z) { Preconditions.checkArgument(findEntryByValue == -1, "Value already present: %s", v); } else if (findEntryByValue != -1) { removeEntryValueHashKnown(findEntryByValue, smearedHash2); } ensureCapacity(this.size + 1); K[] kArr = this.keys; int i = this.size; kArr[i] = k; this.values[i] = v; insertIntoTableKToV(i, smearedHash); insertIntoTableVToK(this.size, smearedHash2); setSucceeds(this.lastInInsertionOrder, this.size); setSucceeds(this.size, -2); this.size++; this.modCount++; return null; } @Override // com.google.common.collect.BiMap @CheckForNull public V forcePut(@ParametricNullness K k, @ParametricNullness V v) { return put(k, v, true); } @CheckForNull K putInverse(@ParametricNullness V v, @ParametricNullness K k, boolean z) { int smearedHash = Hashing.smearedHash(v); int findEntryByValue = findEntryByValue(v, smearedHash); if (findEntryByValue != -1) { K k2 = this.keys[findEntryByValue]; if (Objects.equal(k2, k)) { return k; } replaceKeyInEntry(findEntryByValue, k, z); return k2; } int i = this.lastInInsertionOrder; int smearedHash2 = Hashing.smearedHash(k); int findEntryByKey = findEntryByKey(k, smearedHash2); if (!z) { Preconditions.checkArgument(findEntryByKey == -1, "Key already present: %s", k); } else if (findEntryByKey != -1) { i = this.prevInInsertionOrder[findEntryByKey]; removeEntryKeyHashKnown(findEntryByKey, smearedHash2); } ensureCapacity(this.size + 1); K[] kArr = this.keys; int i2 = this.size; kArr[i2] = k; this.values[i2] = v; insertIntoTableKToV(i2, smearedHash2); insertIntoTableVToK(this.size, smearedHash); int i3 = i == -2 ? this.firstInInsertionOrder : this.nextInInsertionOrder[i]; setSucceeds(i, this.size); setSucceeds(this.size, i3); this.size++; this.modCount++; return null; } private void setSucceeds(int i, int i2) { if (i == -2) { this.firstInInsertionOrder = i2; } else { this.nextInInsertionOrder[i] = i2; } if (i2 == -2) { this.lastInInsertionOrder = i; } else { this.prevInInsertionOrder[i2] = i; } } private void insertIntoTableKToV(int i, int i2) { Preconditions.checkArgument(i != -1); int bucket = bucket(i2); int[] iArr = this.nextInBucketKToV; int[] iArr2 = this.hashTableKToV; iArr[i] = iArr2[bucket]; iArr2[bucket] = i; } private void insertIntoTableVToK(int i, int i2) { Preconditions.checkArgument(i != -1); int bucket = bucket(i2); int[] iArr = this.nextInBucketVToK; int[] iArr2 = this.hashTableVToK; iArr[i] = iArr2[bucket]; iArr2[bucket] = i; } private void deleteFromTableKToV(int i, int i2) { Preconditions.checkArgument(i != -1); int bucket = bucket(i2); int[] iArr = this.hashTableKToV; int i3 = iArr[bucket]; if (i3 == i) { int[] iArr2 = this.nextInBucketKToV; iArr[bucket] = iArr2[i]; iArr2[i] = -1; return; } int i4 = this.nextInBucketKToV[i3]; while (true) { int i5 = i3; i3 = i4; if (i3 == -1) { String valueOf = String.valueOf(this.keys[i]); throw new AssertionError(new StringBuilder(String.valueOf(valueOf).length() + 32).append("Expected to find entry with key ").append(valueOf).toString()); } if (i3 != i) { i4 = this.nextInBucketKToV[i3]; } else { int[] iArr3 = this.nextInBucketKToV; iArr3[i5] = iArr3[i]; iArr3[i] = -1; return; } } } private void deleteFromTableVToK(int i, int i2) { Preconditions.checkArgument(i != -1); int bucket = bucket(i2); int[] iArr = this.hashTableVToK; int i3 = iArr[bucket]; if (i3 == i) { int[] iArr2 = this.nextInBucketVToK; iArr[bucket] = iArr2[i]; iArr2[i] = -1; return; } int i4 = this.nextInBucketVToK[i3]; while (true) { int i5 = i3; i3 = i4; if (i3 == -1) { String valueOf = String.valueOf(this.values[i]); throw new AssertionError(new StringBuilder(String.valueOf(valueOf).length() + 34).append("Expected to find entry with value ").append(valueOf).toString()); } if (i3 != i) { i4 = this.nextInBucketVToK[i3]; } else { int[] iArr3 = this.nextInBucketVToK; iArr3[i5] = iArr3[i]; iArr3[i] = -1; return; } } } /* JADX INFO: Access modifiers changed from: private */ public void replaceValueInEntry(int i, @ParametricNullness V v, boolean z) { Preconditions.checkArgument(i != -1); int smearedHash = Hashing.smearedHash(v); int findEntryByValue = findEntryByValue(v, smearedHash); if (findEntryByValue != -1) { if (z) { removeEntryValueHashKnown(findEntryByValue, smearedHash); if (i == this.size) { i = findEntryByValue; } } else { String valueOf = String.valueOf(v); throw new IllegalArgumentException(new StringBuilder(String.valueOf(valueOf).length() + 30).append("Value already present in map: ").append(valueOf).toString()); } } deleteFromTableVToK(i, Hashing.smearedHash(this.values[i])); this.values[i] = v; insertIntoTableVToK(i, smearedHash); } /* JADX INFO: Access modifiers changed from: private */ public void replaceKeyInEntry(int i, @ParametricNullness K k, boolean z) { int i2; Preconditions.checkArgument(i != -1); int smearedHash = Hashing.smearedHash(k); int findEntryByKey = findEntryByKey(k, smearedHash); int i3 = this.lastInInsertionOrder; if (findEntryByKey == -1) { i2 = -2; } else if (z) { i3 = this.prevInInsertionOrder[findEntryByKey]; i2 = this.nextInInsertionOrder[findEntryByKey]; removeEntryKeyHashKnown(findEntryByKey, smearedHash); if (i == this.size) { i = findEntryByKey; } } else { String valueOf = String.valueOf(k); throw new IllegalArgumentException(new StringBuilder(String.valueOf(valueOf).length() + 28).append("Key already present in map: ").append(valueOf).toString()); } if (i3 == i) { i3 = this.prevInInsertionOrder[i]; } else if (i3 == this.size) { i3 = findEntryByKey; } if (i2 == i) { findEntryByKey = this.nextInInsertionOrder[i]; } else if (i2 != this.size) { findEntryByKey = i2; } setSucceeds(this.prevInInsertionOrder[i], this.nextInInsertionOrder[i]); deleteFromTableKToV(i, Hashing.smearedHash(this.keys[i])); this.keys[i] = k; insertIntoTableKToV(i, Hashing.smearedHash(k)); setSucceeds(i3, i); setSucceeds(i, findEntryByKey); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public V remove(@CheckForNull Object obj) { int smearedHash = Hashing.smearedHash(obj); int findEntryByKey = findEntryByKey(obj, smearedHash); if (findEntryByKey == -1) { return null; } V v = this.values[findEntryByKey]; removeEntryKeyHashKnown(findEntryByKey, smearedHash); return v; } @CheckForNull K removeInverse(@CheckForNull Object obj) { int smearedHash = Hashing.smearedHash(obj); int findEntryByValue = findEntryByValue(obj, smearedHash); if (findEntryByValue == -1) { return null; } K k = this.keys[findEntryByValue]; removeEntryValueHashKnown(findEntryByValue, smearedHash); return k; } void removeEntry(int i) { removeEntryKeyHashKnown(i, Hashing.smearedHash(this.keys[i])); } private void removeEntry(int i, int i2, int i3) { Preconditions.checkArgument(i != -1); deleteFromTableKToV(i, i2); deleteFromTableVToK(i, i3); setSucceeds(this.prevInInsertionOrder[i], this.nextInInsertionOrder[i]); moveEntryToIndex(this.size - 1, i); K[] kArr = this.keys; int i4 = this.size; kArr[i4 - 1] = null; this.values[i4 - 1] = null; this.size = i4 - 1; this.modCount++; } void removeEntryKeyHashKnown(int i, int i2) { removeEntry(i, i2, Hashing.smearedHash(this.values[i])); } void removeEntryValueHashKnown(int i, int i2) { removeEntry(i, Hashing.smearedHash(this.keys[i]), i2); } private void moveEntryToIndex(int i, int i2) { int i3; int i4; if (i == i2) { return; } int i5 = this.prevInInsertionOrder[i]; int i6 = this.nextInInsertionOrder[i]; setSucceeds(i5, i2); setSucceeds(i2, i6); K[] kArr = this.keys; K k = kArr[i]; V[] vArr = this.values; V v = vArr[i]; kArr[i2] = k; vArr[i2] = v; int bucket = bucket(Hashing.smearedHash(k)); int[] iArr = this.hashTableKToV; int i7 = iArr[bucket]; if (i7 == i) { iArr[bucket] = i2; } else { int i8 = this.nextInBucketKToV[i7]; while (true) { i3 = i7; i7 = i8; if (i7 == i) { break; } else { i8 = this.nextInBucketKToV[i7]; } } this.nextInBucketKToV[i3] = i2; } int[] iArr2 = this.nextInBucketKToV; iArr2[i2] = iArr2[i]; iArr2[i] = -1; int bucket2 = bucket(Hashing.smearedHash(v)); int[] iArr3 = this.hashTableVToK; int i9 = iArr3[bucket2]; if (i9 == i) { iArr3[bucket2] = i2; } else { int i10 = this.nextInBucketVToK[i9]; while (true) { i4 = i9; i9 = i10; if (i9 == i) { break; } else { i10 = this.nextInBucketVToK[i9]; } } this.nextInBucketVToK[i4] = i2; } int[] iArr4 = this.nextInBucketVToK; iArr4[i2] = iArr4[i]; iArr4[i] = -1; } @Override // java.util.AbstractMap, java.util.Map public void clear() { Arrays.fill(this.keys, 0, this.size, (Object) null); Arrays.fill(this.values, 0, this.size, (Object) null); Arrays.fill(this.hashTableKToV, -1); Arrays.fill(this.hashTableVToK, -1); Arrays.fill(this.nextInBucketKToV, 0, this.size, -1); Arrays.fill(this.nextInBucketVToK, 0, this.size, -1); Arrays.fill(this.prevInInsertionOrder, 0, this.size, -1); Arrays.fill(this.nextInInsertionOrder, 0, this.size, -1); this.size = 0; this.firstInInsertionOrder = -2; this.lastInInsertionOrder = -2; this.modCount++; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static abstract class View extends AbstractSet { final HashBiMap biMap; @ParametricNullness abstract T forEntry(int i); View(HashBiMap hashBiMap) { this.biMap = hashBiMap; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return new Iterator() { // from class: com.google.common.collect.HashBiMap.View.1 private int expectedModCount; private int index; private int indexToRemove = -1; private int remaining; { this.index = ((HashBiMap) View.this.biMap).firstInInsertionOrder; this.expectedModCount = View.this.biMap.modCount; this.remaining = View.this.biMap.size; } private void checkForComodification() { if (View.this.biMap.modCount != this.expectedModCount) { throw new ConcurrentModificationException(); } } @Override // java.util.Iterator public boolean hasNext() { checkForComodification(); return this.index != -2 && this.remaining > 0; } @Override // java.util.Iterator @ParametricNullness public T next() { if (!hasNext()) { throw new NoSuchElementException(); } T t = (T) View.this.forEntry(this.index); this.indexToRemove = this.index; this.index = ((HashBiMap) View.this.biMap).nextInInsertionOrder[this.index]; this.remaining--; return t; } @Override // java.util.Iterator public void remove() { checkForComodification(); CollectPreconditions.checkRemove(this.indexToRemove != -1); View.this.biMap.removeEntry(this.indexToRemove); if (this.index == View.this.biMap.size) { this.index = this.indexToRemove; } this.indexToRemove = -1; this.expectedModCount = View.this.biMap.modCount; } }; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return this.biMap.size; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { this.biMap.clear(); } } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { Set set = this.keySet; if (set != null) { return set; } KeySet keySet = new KeySet(); this.keySet = keySet; return keySet; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public final class KeySet extends View { KeySet() { super(HashBiMap.this); } @Override // com.google.common.collect.HashBiMap.View @ParametricNullness K forEntry(int i) { return (K) NullnessCasts.uncheckedCastNullableTToT(HashBiMap.this.keys[i]); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { return HashBiMap.this.containsKey(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { int smearedHash = Hashing.smearedHash(obj); int findEntryByKey = HashBiMap.this.findEntryByKey(obj, smearedHash); if (findEntryByKey == -1) { return false; } HashBiMap.this.removeEntryKeyHashKnown(findEntryByKey, smearedHash); return true; } } @Override // java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap public Set values() { Set set = this.valueSet; if (set != null) { return set; } ValueSet valueSet = new ValueSet(); this.valueSet = valueSet; return valueSet; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public final class ValueSet extends View { ValueSet() { super(HashBiMap.this); } @Override // com.google.common.collect.HashBiMap.View @ParametricNullness V forEntry(int i) { return (V) NullnessCasts.uncheckedCastNullableTToT(HashBiMap.this.values[i]); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { return HashBiMap.this.containsValue(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { int smearedHash = Hashing.smearedHash(obj); int findEntryByValue = HashBiMap.this.findEntryByValue(obj, smearedHash); if (findEntryByValue == -1) { return false; } HashBiMap.this.removeEntryValueHashKnown(findEntryByValue, smearedHash); return true; } } @Override // java.util.AbstractMap, java.util.Map public Set> entrySet() { Set> set = this.entrySet; if (set != null) { return set; } EntrySet entrySet = new EntrySet(); this.entrySet = entrySet; return entrySet; } /* loaded from: classes3.dex */ final class EntrySet extends View> { EntrySet() { super(HashBiMap.this); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; Object key = entry.getKey(); Object value = entry.getValue(); int findEntryByKey = HashBiMap.this.findEntryByKey(key); return findEntryByKey != -1 && Objects.equal(value, HashBiMap.this.values[findEntryByKey]); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; Object key = entry.getKey(); Object value = entry.getValue(); int smearedHash = Hashing.smearedHash(key); int findEntryByKey = HashBiMap.this.findEntryByKey(key, smearedHash); if (findEntryByKey == -1 || !Objects.equal(value, HashBiMap.this.values[findEntryByKey])) { return false; } HashBiMap.this.removeEntryKeyHashKnown(findEntryByKey, smearedHash); return true; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.HashBiMap.View public Map.Entry forEntry(int i) { return new EntryForKey(i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public final class EntryForKey extends AbstractMapEntry { int index; @ParametricNullness final K key; @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public K getKey() { return this.key; } EntryForKey(int i) { this.key = (K) NullnessCasts.uncheckedCastNullableTToT(HashBiMap.this.keys[i]); this.index = i; } void updateIndex() { int i = this.index; if (i == -1 || i > HashBiMap.this.size || !Objects.equal(HashBiMap.this.keys[this.index], this.key)) { this.index = HashBiMap.this.findEntryByKey(this.key); } } @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public V getValue() { updateIndex(); return this.index == -1 ? (V) NullnessCasts.unsafeNull() : (V) NullnessCasts.uncheckedCastNullableTToT(HashBiMap.this.values[this.index]); } @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public V setValue(@ParametricNullness V v) { updateIndex(); if (this.index == -1) { HashBiMap.this.put(this.key, v); return (V) NullnessCasts.unsafeNull(); } V v2 = (V) NullnessCasts.uncheckedCastNullableTToT(HashBiMap.this.values[this.index]); if (Objects.equal(v2, v)) { return v; } HashBiMap.this.replaceValueInEntry(this.index, v, false); return v2; } } @Override // com.google.common.collect.BiMap public BiMap inverse() { BiMap biMap = this.inverse; if (biMap != null) { return biMap; } Inverse inverse = new Inverse(this); this.inverse = inverse; return inverse; } /* loaded from: classes3.dex */ static class Inverse extends AbstractMap implements BiMap, Serializable { private final HashBiMap forward; private transient Set> inverseEntrySet; @Override // com.google.common.collect.BiMap public BiMap inverse() { return this.forward; } Inverse(HashBiMap hashBiMap) { this.forward = hashBiMap; } @Override // java.util.AbstractMap, java.util.Map public int size() { return this.forward.size; } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(@CheckForNull Object obj) { return this.forward.containsValue(obj); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public K get(@CheckForNull Object obj) { return this.forward.getInverse(obj); } @Override // java.util.AbstractMap, java.util.Map public boolean containsValue(@CheckForNull Object obj) { return this.forward.containsKey(obj); } @Override // java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap @CheckForNull public K put(@ParametricNullness V v, @ParametricNullness K k) { return this.forward.putInverse(v, k, false); } @Override // com.google.common.collect.BiMap @CheckForNull public K forcePut(@ParametricNullness V v, @ParametricNullness K k) { return this.forward.putInverse(v, k, true); } @Override // java.util.AbstractMap, java.util.Map @CheckForNull public K remove(@CheckForNull Object obj) { return this.forward.removeInverse(obj); } @Override // java.util.AbstractMap, java.util.Map public void clear() { this.forward.clear(); } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { return this.forward.values(); } @Override // java.util.AbstractMap, java.util.Map, com.google.common.collect.BiMap public Set values() { return this.forward.keySet(); } @Override // java.util.AbstractMap, java.util.Map public Set> entrySet() { Set> set = this.inverseEntrySet; if (set != null) { return set; } InverseEntrySet inverseEntrySet = new InverseEntrySet(this.forward); this.inverseEntrySet = inverseEntrySet; return inverseEntrySet; } private void readObject(ObjectInputStream objectInputStream) throws ClassNotFoundException, IOException { objectInputStream.defaultReadObject(); ((HashBiMap) this.forward).inverse = this; } } /* loaded from: classes3.dex */ static class InverseEntrySet extends View> { InverseEntrySet(HashBiMap hashBiMap) { super(hashBiMap); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; Object key = entry.getKey(); Object value = entry.getValue(); int findEntryByValue = this.biMap.findEntryByValue(key); return findEntryByValue != -1 && Objects.equal(this.biMap.keys[findEntryByValue], value); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; Object key = entry.getKey(); Object value = entry.getValue(); int smearedHash = Hashing.smearedHash(key); int findEntryByValue = this.biMap.findEntryByValue(key, smearedHash); if (findEntryByValue == -1 || !Objects.equal(this.biMap.keys[findEntryByValue], value)) { return false; } this.biMap.removeEntryValueHashKnown(findEntryByValue, smearedHash); return true; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.HashBiMap.View public Map.Entry forEntry(int i) { return new EntryForValue(this.biMap, i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public static final class EntryForValue extends AbstractMapEntry { final HashBiMap biMap; int index; @ParametricNullness final V value; @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public V getKey() { return this.value; } EntryForValue(HashBiMap hashBiMap, int i) { this.biMap = hashBiMap; this.value = (V) NullnessCasts.uncheckedCastNullableTToT(hashBiMap.values[i]); this.index = i; } private void updateIndex() { int i = this.index; if (i == -1 || i > this.biMap.size || !Objects.equal(this.value, this.biMap.values[this.index])) { this.index = this.biMap.findEntryByValue(this.value); } } @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public K getValue() { updateIndex(); return this.index == -1 ? (K) NullnessCasts.unsafeNull() : (K) NullnessCasts.uncheckedCastNullableTToT(this.biMap.keys[this.index]); } @Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry @ParametricNullness public K setValue(@ParametricNullness K k) { updateIndex(); if (this.index == -1) { this.biMap.putInverse(this.value, k, false); return (K) NullnessCasts.unsafeNull(); } K k2 = (K) NullnessCasts.uncheckedCastNullableTToT(this.biMap.keys[this.index]); if (Objects.equal(k2, k)) { return k; } this.biMap.replaceKeyInEntry(this.index, k, false); return k2; } } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); Serialization.writeMap(this, objectOutputStream); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); int readCount = Serialization.readCount(objectInputStream); init(16); Serialization.populateMap(this, objectInputStream, readCount); } }