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

2417 lines
104 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.google.common.base.Equivalence;
import com.google.common.base.Preconditions;
import com.google.common.collect.MapMaker;
import com.google.common.collect.MapMakerInternalMap.InternalEntry;
import com.google.common.collect.MapMakerInternalMap.Segment;
import com.google.common.primitives.Ints;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.locks.ReentrantLock;
import o.C13415fZr;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class MapMakerInternalMap<K, V, E extends InternalEntry<K, V, E>, S extends Segment<K, V, E, S>> extends AbstractMap<K, V> implements ConcurrentMap<K, V>, Serializable {
static final long CLEANUP_EXECUTOR_DELAY_SECS = 60;
static final int CONTAINS_VALUE_RETRIES = 3;
static final int DRAIN_MAX = 16;
static final int DRAIN_THRESHOLD = 63;
static final int MAXIMUM_CAPACITY = 1073741824;
static final int MAX_SEGMENTS = 65536;
static final WeakValueReference<Object, Object, DummyInternalEntry> UNSET_WEAK_VALUE_REFERENCE = new WeakValueReference<Object, Object, DummyInternalEntry>() { // from class: com.google.common.collect.MapMakerInternalMap.1
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public void clear() {
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public WeakValueReference<Object, Object, DummyInternalEntry> copyFor(ReferenceQueue<Object> referenceQueue, DummyInternalEntry dummyInternalEntry) {
return this;
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public Object get() {
return null;
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public DummyInternalEntry getEntry() {
return null;
}
};
private static final long serialVersionUID = 5;
final int concurrencyLevel;
final transient InternalEntryHelper<K, V, E, S> entryHelper;
transient Set<Map.Entry<K, V>> entrySet;
final Equivalence<Object> keyEquivalence;
transient Set<K> keySet;
final transient int segmentMask;
final transient int segmentShift;
final transient Segment<K, V, E, S>[] segments;
transient Collection<V> values;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public interface InternalEntry<K, V, E extends InternalEntry<K, V, E>> {
int getHash();
K getKey();
E getNext();
V getValue();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public interface InternalEntryHelper<K, V, E extends InternalEntry<K, V, E>, S extends Segment<K, V, E, S>> {
E copy(S s, E e, E e2);
Strength keyStrength();
E newEntry(S s, K k, int i, E e);
S newSegment(MapMakerInternalMap<K, V, E, S> mapMakerInternalMap, int i, int i2);
void setValue(S s, E e, V v);
Strength valueStrength();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public enum Strength {
STRONG { // from class: com.google.common.collect.MapMakerInternalMap.Strength.1
@Override // com.google.common.collect.MapMakerInternalMap.Strength
final Equivalence<Object> defaultEquivalence() {
return Equivalence.equals();
}
},
WEAK { // from class: com.google.common.collect.MapMakerInternalMap.Strength.2
@Override // com.google.common.collect.MapMakerInternalMap.Strength
final Equivalence<Object> defaultEquivalence() {
return Equivalence.identity();
}
};
/* JADX INFO: Access modifiers changed from: package-private */
public abstract Equivalence<Object> defaultEquivalence();
}
/* loaded from: classes2.dex */
interface StrongValueEntry<K, V, E extends InternalEntry<K, V, E>> extends InternalEntry<K, V, E> {
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public interface WeakValueEntry<K, V, E extends InternalEntry<K, V, E>> extends InternalEntry<K, V, E> {
void clearValue();
WeakValueReference<K, V, E> getValueReference();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public interface WeakValueReference<K, V, E extends InternalEntry<K, V, E>> {
void clear();
WeakValueReference<K, V, E> copyFor(ReferenceQueue<V> referenceQueue, E e);
V get();
E getEntry();
}
static int rehash(int i) {
int i2 = i + ((i << 15) ^ (-12931));
int i3 = i2 ^ (i2 >>> 10);
int i4 = i3 + (i3 << 3);
int i5 = i4 ^ (i4 >>> 6);
int i6 = i5 + (i5 << 2) + (i5 << 14);
return i6 ^ (i6 >>> 16);
}
private MapMakerInternalMap(MapMaker mapMaker, InternalEntryHelper<K, V, E, S> internalEntryHelper) {
this.concurrencyLevel = Math.min(mapMaker.getConcurrencyLevel(), 65536);
this.keyEquivalence = mapMaker.getKeyEquivalence();
this.entryHelper = internalEntryHelper;
int min = Math.min(mapMaker.getInitialCapacity(), 1073741824);
int i = 0;
int i2 = 1;
int i3 = 0;
int i4 = 1;
while (i4 < this.concurrencyLevel) {
i3++;
i4 <<= 1;
}
this.segmentShift = 32 - i3;
this.segmentMask = i4 - 1;
this.segments = newSegmentArray(i4);
int i5 = min / i4;
while (i2 < (i4 * i5 < min ? i5 + 1 : i5)) {
i2 <<= 1;
}
while (true) {
Segment<K, V, E, S>[] segmentArr = this.segments;
if (i >= segmentArr.length) {
return;
}
segmentArr[i] = createSegment(i2, -1);
i++;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create(MapMaker mapMaker) {
if (mapMaker.getKeyStrength() == Strength.STRONG && mapMaker.getValueStrength() == Strength.STRONG) {
return new MapMakerInternalMap<>(mapMaker, StrongKeyStrongValueEntry.Helper.instance());
}
if (mapMaker.getKeyStrength() == Strength.STRONG && mapMaker.getValueStrength() == Strength.WEAK) {
return new MapMakerInternalMap<>(mapMaker, StrongKeyWeakValueEntry.Helper.instance());
}
if (mapMaker.getKeyStrength() == Strength.WEAK && mapMaker.getValueStrength() == Strength.STRONG) {
return new MapMakerInternalMap<>(mapMaker, WeakKeyStrongValueEntry.Helper.instance());
}
if (mapMaker.getKeyStrength() == Strength.WEAK && mapMaker.getValueStrength() == Strength.WEAK) {
return new MapMakerInternalMap<>(mapMaker, WeakKeyWeakValueEntry.Helper.instance());
}
throw new AssertionError();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K> MapMakerInternalMap<K, MapMaker.Dummy, ? extends InternalEntry<K, MapMaker.Dummy, ?>, ?> createWithDummyValues(MapMaker mapMaker) {
if (mapMaker.getKeyStrength() == Strength.STRONG && mapMaker.getValueStrength() == Strength.STRONG) {
return new MapMakerInternalMap<>(mapMaker, StrongKeyDummyValueEntry.Helper.instance());
}
if (mapMaker.getKeyStrength() == Strength.WEAK && mapMaker.getValueStrength() == Strength.STRONG) {
return new MapMakerInternalMap<>(mapMaker, WeakKeyDummyValueEntry.Helper.instance());
}
if (mapMaker.getValueStrength() == Strength.WEAK) {
throw new IllegalArgumentException("Map cannot have both weak and dummy values");
}
throw new AssertionError();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class AbstractStrongKeyEntry<K, V, E extends InternalEntry<K, V, E>> implements InternalEntry<K, V, E> {
final int hash;
final K key;
final E next;
AbstractStrongKeyEntry(K k, int i, E e) {
this.key = k;
this.hash = i;
this.next = e;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public E getNext() {
return this.next;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public K getKey() {
return this.key;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public int getHash() {
return this.hash;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyStrongValueEntry<K, V> extends AbstractStrongKeyEntry<K, V, StrongKeyStrongValueEntry<K, V>> implements StrongValueEntry<K, V, StrongKeyStrongValueEntry<K, V>> {
private volatile V value;
StrongKeyStrongValueEntry(K k, int i, StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry) {
super(k, i, strongKeyStrongValueEntry);
this.value = null;
}
final StrongKeyStrongValueEntry<K, V> copy(StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry) {
StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry2 = new StrongKeyStrongValueEntry<>(this.key, this.hash, strongKeyStrongValueEntry);
strongKeyStrongValueEntry2.value = this.value;
return strongKeyStrongValueEntry2;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class Helper<K, V> implements InternalEntryHelper<K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueSegment<K, V>> {
private static final Helper<?, ?> INSTANCE = new Helper<>();
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((StrongKeyStrongValueSegment<StrongKeyStrongValueSegment<K, V>, V>) segment, (StrongKeyStrongValueSegment<K, V>) obj, i, (StrongKeyStrongValueEntry<StrongKeyStrongValueSegment<K, V>, V>) internalEntry);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ void setValue(Segment segment, InternalEntry internalEntry, Object obj) {
setValue((StrongKeyStrongValueSegment<K, StrongKeyStrongValueEntry<K, V>>) segment, (StrongKeyStrongValueEntry<K, StrongKeyStrongValueEntry<K, V>>) internalEntry, (StrongKeyStrongValueEntry<K, V>) obj);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyStrongValueSegment<K, V> newSegment(MapMakerInternalMap<K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
return new StrongKeyStrongValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyStrongValueEntry<K, V> copy(StrongKeyStrongValueSegment<K, V> strongKeyStrongValueSegment, StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry, StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry2) {
return strongKeyStrongValueEntry.copy(strongKeyStrongValueEntry2);
}
public final void setValue(StrongKeyStrongValueSegment<K, V> strongKeyStrongValueSegment, StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry, V v) {
strongKeyStrongValueEntry.setValue(v);
}
public final StrongKeyStrongValueEntry<K, V> newEntry(StrongKeyStrongValueSegment<K, V> strongKeyStrongValueSegment, K k, int i, StrongKeyStrongValueEntry<K, V> strongKeyStrongValueEntry) {
return new StrongKeyStrongValueEntry<>(k, i, strongKeyStrongValueEntry);
}
static <K, V> Helper<K, V> instance() {
return (Helper<K, V>) INSTANCE;
}
}
final void setValue(V v) {
this.value = v;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final V getValue() {
return this.value;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyWeakValueEntry<K, V> extends AbstractStrongKeyEntry<K, V, StrongKeyWeakValueEntry<K, V>> implements WeakValueEntry<K, V, StrongKeyWeakValueEntry<K, V>> {
private volatile WeakValueReference<K, V, StrongKeyWeakValueEntry<K, V>> valueReference;
StrongKeyWeakValueEntry(K k, int i, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry) {
super(k, i, strongKeyWeakValueEntry);
this.valueReference = MapMakerInternalMap.unsetWeakValueReference();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final V getValue() {
return this.valueReference.get();
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueEntry
public final void clearValue() {
this.valueReference.clear();
}
final void setValue(V v, ReferenceQueue<V> referenceQueue) {
WeakValueReference<K, V, StrongKeyWeakValueEntry<K, V>> weakValueReference = this.valueReference;
this.valueReference = new WeakValueReferenceImpl(referenceQueue, v, this);
weakValueReference.clear();
}
final StrongKeyWeakValueEntry<K, V> copy(ReferenceQueue<V> referenceQueue, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry) {
StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry2 = new StrongKeyWeakValueEntry<>(this.key, this.hash, strongKeyWeakValueEntry);
strongKeyWeakValueEntry2.valueReference = this.valueReference.copyFor(referenceQueue, strongKeyWeakValueEntry2);
return strongKeyWeakValueEntry2;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class Helper<K, V> implements InternalEntryHelper<K, V, StrongKeyWeakValueEntry<K, V>, StrongKeyWeakValueSegment<K, V>> {
private static final Helper<?, ?> INSTANCE = new Helper<>();
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((StrongKeyWeakValueSegment<StrongKeyWeakValueSegment<K, V>, V>) segment, (StrongKeyWeakValueSegment<K, V>) obj, i, (StrongKeyWeakValueEntry<StrongKeyWeakValueSegment<K, V>, V>) internalEntry);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ void setValue(Segment segment, InternalEntry internalEntry, Object obj) {
setValue((StrongKeyWeakValueSegment<K, StrongKeyWeakValueEntry<K, V>>) segment, (StrongKeyWeakValueEntry<K, StrongKeyWeakValueEntry<K, V>>) internalEntry, (StrongKeyWeakValueEntry<K, V>) obj);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.WEAK;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyWeakValueSegment<K, V> newSegment(MapMakerInternalMap<K, V, StrongKeyWeakValueEntry<K, V>, StrongKeyWeakValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
return new StrongKeyWeakValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyWeakValueEntry<K, V> copy(StrongKeyWeakValueSegment<K, V> strongKeyWeakValueSegment, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry2) {
if (Segment.isCollected(strongKeyWeakValueEntry)) {
return null;
}
return strongKeyWeakValueEntry.copy(((StrongKeyWeakValueSegment) strongKeyWeakValueSegment).queueForValues, strongKeyWeakValueEntry2);
}
public final void setValue(StrongKeyWeakValueSegment<K, V> strongKeyWeakValueSegment, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry, V v) {
strongKeyWeakValueEntry.setValue(v, ((StrongKeyWeakValueSegment) strongKeyWeakValueSegment).queueForValues);
}
public final StrongKeyWeakValueEntry<K, V> newEntry(StrongKeyWeakValueSegment<K, V> strongKeyWeakValueSegment, K k, int i, StrongKeyWeakValueEntry<K, V> strongKeyWeakValueEntry) {
return new StrongKeyWeakValueEntry<>(k, i, strongKeyWeakValueEntry);
}
static <K, V> Helper<K, V> instance() {
return (Helper<K, V>) INSTANCE;
}
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueEntry
public final WeakValueReference<K, V, StrongKeyWeakValueEntry<K, V>> getValueReference() {
return this.valueReference;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyDummyValueEntry<K> extends AbstractStrongKeyEntry<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>> implements StrongValueEntry<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>> {
final void setValue(MapMaker.Dummy dummy) {
}
StrongKeyDummyValueEntry(K k, int i, StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry) {
super(k, i, strongKeyDummyValueEntry);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final MapMaker.Dummy getValue() {
return MapMaker.Dummy.VALUE;
}
final StrongKeyDummyValueEntry<K> copy(StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry) {
return new StrongKeyDummyValueEntry<>(this.key, this.hash, strongKeyDummyValueEntry);
}
/* loaded from: classes2.dex */
static final class Helper<K> implements InternalEntryHelper<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>, StrongKeyDummyValueSegment<K>> {
private static final Helper<?> INSTANCE = new Helper<>();
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final void setValue(StrongKeyDummyValueSegment<K> strongKeyDummyValueSegment, StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry, MapMaker.Dummy dummy) {
}
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((StrongKeyDummyValueSegment<StrongKeyDummyValueSegment<K>>) segment, (StrongKeyDummyValueSegment<K>) obj, i, (StrongKeyDummyValueEntry<StrongKeyDummyValueSegment<K>>) internalEntry);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyDummyValueSegment<K> newSegment(MapMakerInternalMap<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>, StrongKeyDummyValueSegment<K>> mapMakerInternalMap, int i, int i2) {
return new StrongKeyDummyValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final StrongKeyDummyValueEntry<K> copy(StrongKeyDummyValueSegment<K> strongKeyDummyValueSegment, StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry, StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry2) {
return strongKeyDummyValueEntry.copy(strongKeyDummyValueEntry2);
}
public final StrongKeyDummyValueEntry<K> newEntry(StrongKeyDummyValueSegment<K> strongKeyDummyValueSegment, K k, int i, StrongKeyDummyValueEntry<K> strongKeyDummyValueEntry) {
return new StrongKeyDummyValueEntry<>(k, i, strongKeyDummyValueEntry);
}
static <K> Helper<K> instance() {
return (Helper<K>) INSTANCE;
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class AbstractWeakKeyEntry<K, V, E extends InternalEntry<K, V, E>> extends WeakReference<K> implements InternalEntry<K, V, E> {
final int hash;
final E next;
AbstractWeakKeyEntry(ReferenceQueue<K> referenceQueue, K k, int i, E e) {
super(k, referenceQueue);
this.hash = i;
this.next = e;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public K getKey() {
return get();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public E getNext() {
return this.next;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public int getHash() {
return this.hash;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyDummyValueEntry<K> extends AbstractWeakKeyEntry<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>> implements StrongValueEntry<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>> {
final void setValue(MapMaker.Dummy dummy) {
}
WeakKeyDummyValueEntry(ReferenceQueue<K> referenceQueue, K k, int i, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry) {
super(referenceQueue, k, i, weakKeyDummyValueEntry);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final MapMaker.Dummy getValue() {
return MapMaker.Dummy.VALUE;
}
final WeakKeyDummyValueEntry<K> copy(ReferenceQueue<K> referenceQueue, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry) {
return new WeakKeyDummyValueEntry<>(referenceQueue, getKey(), this.hash, weakKeyDummyValueEntry);
}
/* loaded from: classes2.dex */
static final class Helper<K> implements InternalEntryHelper<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>, WeakKeyDummyValueSegment<K>> {
private static final Helper<?> INSTANCE = new Helper<>();
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final void setValue(WeakKeyDummyValueSegment<K> weakKeyDummyValueSegment, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry, MapMaker.Dummy dummy) {
}
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((WeakKeyDummyValueSegment<WeakKeyDummyValueSegment<K>>) segment, (WeakKeyDummyValueSegment<K>) obj, i, (WeakKeyDummyValueEntry<WeakKeyDummyValueSegment<K>>) internalEntry);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.WEAK;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyDummyValueSegment<K> newSegment(MapMakerInternalMap<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>, WeakKeyDummyValueSegment<K>> mapMakerInternalMap, int i, int i2) {
return new WeakKeyDummyValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyDummyValueEntry<K> copy(WeakKeyDummyValueSegment<K> weakKeyDummyValueSegment, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry2) {
if (weakKeyDummyValueEntry.getKey() == null) {
return null;
}
return weakKeyDummyValueEntry.copy(((WeakKeyDummyValueSegment) weakKeyDummyValueSegment).queueForKeys, weakKeyDummyValueEntry2);
}
public final WeakKeyDummyValueEntry<K> newEntry(WeakKeyDummyValueSegment<K> weakKeyDummyValueSegment, K k, int i, WeakKeyDummyValueEntry<K> weakKeyDummyValueEntry) {
return new WeakKeyDummyValueEntry<>(((WeakKeyDummyValueSegment) weakKeyDummyValueSegment).queueForKeys, k, i, weakKeyDummyValueEntry);
}
static <K> Helper<K> instance() {
return (Helper<K>) INSTANCE;
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyStrongValueEntry<K, V> extends AbstractWeakKeyEntry<K, V, WeakKeyStrongValueEntry<K, V>> implements StrongValueEntry<K, V, WeakKeyStrongValueEntry<K, V>> {
private volatile V value;
WeakKeyStrongValueEntry(ReferenceQueue<K> referenceQueue, K k, int i, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry) {
super(referenceQueue, k, i, weakKeyStrongValueEntry);
this.value = null;
}
final WeakKeyStrongValueEntry<K, V> copy(ReferenceQueue<K> referenceQueue, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry) {
WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry2 = new WeakKeyStrongValueEntry<>(referenceQueue, getKey(), this.hash, weakKeyStrongValueEntry);
weakKeyStrongValueEntry2.setValue(this.value);
return weakKeyStrongValueEntry2;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class Helper<K, V> implements InternalEntryHelper<K, V, WeakKeyStrongValueEntry<K, V>, WeakKeyStrongValueSegment<K, V>> {
private static final Helper<?, ?> INSTANCE = new Helper<>();
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((WeakKeyStrongValueSegment<WeakKeyStrongValueSegment<K, V>, V>) segment, (WeakKeyStrongValueSegment<K, V>) obj, i, (WeakKeyStrongValueEntry<WeakKeyStrongValueSegment<K, V>, V>) internalEntry);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ void setValue(Segment segment, InternalEntry internalEntry, Object obj) {
setValue((WeakKeyStrongValueSegment<K, WeakKeyStrongValueEntry<K, V>>) segment, (WeakKeyStrongValueEntry<K, WeakKeyStrongValueEntry<K, V>>) internalEntry, (WeakKeyStrongValueEntry<K, V>) obj);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.WEAK;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.STRONG;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyStrongValueSegment<K, V> newSegment(MapMakerInternalMap<K, V, WeakKeyStrongValueEntry<K, V>, WeakKeyStrongValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
return new WeakKeyStrongValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyStrongValueEntry<K, V> copy(WeakKeyStrongValueSegment<K, V> weakKeyStrongValueSegment, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry2) {
if (weakKeyStrongValueEntry.getKey() == null) {
return null;
}
return weakKeyStrongValueEntry.copy(((WeakKeyStrongValueSegment) weakKeyStrongValueSegment).queueForKeys, weakKeyStrongValueEntry2);
}
public final void setValue(WeakKeyStrongValueSegment<K, V> weakKeyStrongValueSegment, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry, V v) {
weakKeyStrongValueEntry.setValue(v);
}
public final WeakKeyStrongValueEntry<K, V> newEntry(WeakKeyStrongValueSegment<K, V> weakKeyStrongValueSegment, K k, int i, WeakKeyStrongValueEntry<K, V> weakKeyStrongValueEntry) {
return new WeakKeyStrongValueEntry<>(((WeakKeyStrongValueSegment) weakKeyStrongValueSegment).queueForKeys, k, i, weakKeyStrongValueEntry);
}
static <K, V> Helper<K, V> instance() {
return (Helper<K, V>) INSTANCE;
}
}
final void setValue(V v) {
this.value = v;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final V getValue() {
return this.value;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyWeakValueEntry<K, V> extends AbstractWeakKeyEntry<K, V, WeakKeyWeakValueEntry<K, V>> implements WeakValueEntry<K, V, WeakKeyWeakValueEntry<K, V>> {
private volatile WeakValueReference<K, V, WeakKeyWeakValueEntry<K, V>> valueReference;
WeakKeyWeakValueEntry(ReferenceQueue<K> referenceQueue, K k, int i, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry) {
super(referenceQueue, k, i, weakKeyWeakValueEntry);
this.valueReference = MapMakerInternalMap.unsetWeakValueReference();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final V getValue() {
return this.valueReference.get();
}
final WeakKeyWeakValueEntry<K, V> copy(ReferenceQueue<K> referenceQueue, ReferenceQueue<V> referenceQueue2, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry) {
WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry2 = new WeakKeyWeakValueEntry<>(referenceQueue, getKey(), this.hash, weakKeyWeakValueEntry);
weakKeyWeakValueEntry2.valueReference = this.valueReference.copyFor(referenceQueue2, weakKeyWeakValueEntry2);
return weakKeyWeakValueEntry2;
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueEntry
public final void clearValue() {
this.valueReference.clear();
}
final void setValue(V v, ReferenceQueue<V> referenceQueue) {
WeakValueReference<K, V, WeakKeyWeakValueEntry<K, V>> weakValueReference = this.valueReference;
this.valueReference = new WeakValueReferenceImpl(referenceQueue, v, this);
weakValueReference.clear();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class Helper<K, V> implements InternalEntryHelper<K, V, WeakKeyWeakValueEntry<K, V>, WeakKeyWeakValueSegment<K, V>> {
private static final Helper<?, ?> INSTANCE = new Helper<>();
Helper() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ InternalEntry newEntry(Segment segment, Object obj, int i, InternalEntry internalEntry) {
return newEntry((WeakKeyWeakValueSegment<WeakKeyWeakValueSegment<K, V>, V>) segment, (WeakKeyWeakValueSegment<K, V>) obj, i, (WeakKeyWeakValueEntry<WeakKeyWeakValueSegment<K, V>, V>) internalEntry);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final /* bridge */ /* synthetic */ void setValue(Segment segment, InternalEntry internalEntry, Object obj) {
setValue((WeakKeyWeakValueSegment<K, WeakKeyWeakValueEntry<K, V>>) segment, (WeakKeyWeakValueEntry<K, WeakKeyWeakValueEntry<K, V>>) internalEntry, (WeakKeyWeakValueEntry<K, V>) obj);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength keyStrength() {
return Strength.WEAK;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final Strength valueStrength() {
return Strength.WEAK;
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyWeakValueSegment<K, V> newSegment(MapMakerInternalMap<K, V, WeakKeyWeakValueEntry<K, V>, WeakKeyWeakValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
return new WeakKeyWeakValueSegment<>(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntryHelper
public final WeakKeyWeakValueEntry<K, V> copy(WeakKeyWeakValueSegment<K, V> weakKeyWeakValueSegment, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry2) {
if (weakKeyWeakValueEntry.getKey() == null || Segment.isCollected(weakKeyWeakValueEntry)) {
return null;
}
return weakKeyWeakValueEntry.copy(((WeakKeyWeakValueSegment) weakKeyWeakValueSegment).queueForKeys, ((WeakKeyWeakValueSegment) weakKeyWeakValueSegment).queueForValues, weakKeyWeakValueEntry2);
}
public final void setValue(WeakKeyWeakValueSegment<K, V> weakKeyWeakValueSegment, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry, V v) {
weakKeyWeakValueEntry.setValue(v, ((WeakKeyWeakValueSegment) weakKeyWeakValueSegment).queueForValues);
}
public final WeakKeyWeakValueEntry<K, V> newEntry(WeakKeyWeakValueSegment<K, V> weakKeyWeakValueSegment, K k, int i, WeakKeyWeakValueEntry<K, V> weakKeyWeakValueEntry) {
return new WeakKeyWeakValueEntry<>(((WeakKeyWeakValueSegment) weakKeyWeakValueSegment).queueForKeys, k, i, weakKeyWeakValueEntry);
}
static <K, V> Helper<K, V> instance() {
return (Helper<K, V>) INSTANCE;
}
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueEntry
public final WeakValueReference<K, V, WeakKeyWeakValueEntry<K, V>> getValueReference() {
return this.valueReference;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class DummyInternalEntry implements InternalEntry<Object, Object, DummyInternalEntry> {
private DummyInternalEntry() {
throw new AssertionError();
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final DummyInternalEntry getNext() {
throw new AssertionError();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final int getHash() {
throw new AssertionError();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final Object getKey() {
throw new AssertionError();
}
@Override // com.google.common.collect.MapMakerInternalMap.InternalEntry
public final Object getValue() {
throw new AssertionError();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakValueReferenceImpl<K, V, E extends InternalEntry<K, V, E>> extends WeakReference<V> implements WeakValueReference<K, V, E> {
final E entry;
WeakValueReferenceImpl(ReferenceQueue<V> referenceQueue, V v, E e) {
super(v, referenceQueue);
this.entry = e;
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public final WeakValueReference<K, V, E> copyFor(ReferenceQueue<V> referenceQueue, E e) {
return new WeakValueReferenceImpl(referenceQueue, get(), e);
}
@Override // com.google.common.collect.MapMakerInternalMap.WeakValueReference
public final E getEntry() {
return this.entry;
}
}
E copyEntry(E e, E e2) {
return segmentFor(e.getHash()).copyEntry(e, e2);
}
int hash(Object obj) {
return rehash(this.keyEquivalence.hash(obj));
}
/* JADX WARN: Multi-variable type inference failed */
void reclaimValue(WeakValueReference<K, V, E> weakValueReference) {
E entry = weakValueReference.getEntry();
int hash = entry.getHash();
segmentFor(hash).reclaimValue(entry.getKey(), hash, weakValueReference);
}
void reclaimKey(E e) {
int hash = e.getHash();
segmentFor(hash).reclaimKey(e, hash);
}
boolean isLiveForTesting(InternalEntry<K, V, ?> internalEntry) {
return segmentFor(internalEntry.getHash()).getLiveValueForTesting(internalEntry) != null;
}
Segment<K, V, E, S> segmentFor(int i) {
return this.segments[(i >>> this.segmentShift) & this.segmentMask];
}
Segment<K, V, E, S> createSegment(int i, int i2) {
return this.entryHelper.newSegment(this, i, i2);
}
V getLiveValue(E e) {
if (e.getKey() == null) {
return null;
}
return (V) e.getValue();
}
final Segment<K, V, E, S>[] newSegmentArray(int i) {
return new Segment[i];
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static abstract class Segment<K, V, E extends InternalEntry<K, V, E>, S extends Segment<K, V, E, S>> extends ReentrantLock {
volatile int count;
final MapMakerInternalMap<K, V, E, S> map;
final int maxSegmentSize;
int modCount;
final AtomicInteger readCount = new AtomicInteger();
volatile AtomicReferenceArray<E> table;
int threshold;
abstract E castForTesting(InternalEntry<K, V, ?> internalEntry);
void maybeClearReferenceQueues() {
}
void maybeDrainReferenceQueues() {
}
abstract S self();
Segment(MapMakerInternalMap<K, V, E, S> mapMakerInternalMap, int i, int i2) {
this.map = mapMakerInternalMap;
this.maxSegmentSize = i2;
initTable(newEntryArray(i));
}
void setValue(E e, V v) {
this.map.entryHelper.setValue(self(), e, v);
}
E copyEntry(E e, E e2) {
return this.map.entryHelper.copy(self(), e, e2);
}
AtomicReferenceArray<E> newEntryArray(int i) {
return new AtomicReferenceArray<>(i);
}
void initTable(AtomicReferenceArray<E> atomicReferenceArray) {
int length = (atomicReferenceArray.length() * 3) / 4;
this.threshold = length;
if (length == this.maxSegmentSize) {
this.threshold = length + 1;
}
this.table = atomicReferenceArray;
}
ReferenceQueue<K> getKeyReferenceQueueForTesting() {
throw new AssertionError();
}
ReferenceQueue<V> getValueReferenceQueueForTesting() {
throw new AssertionError();
}
WeakValueReference<K, V, E> getWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry) {
throw new AssertionError();
}
WeakValueReference<K, V, E> newWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, V v) {
throw new AssertionError();
}
void setWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, WeakValueReference<K, V, ? extends InternalEntry<K, V, ?>> weakValueReference) {
throw new AssertionError();
}
void setTableEntryForTesting(int i, InternalEntry<K, V, ?> internalEntry) {
this.table.set(i, castForTesting(internalEntry));
}
E copyForTesting(InternalEntry<K, V, ?> internalEntry, InternalEntry<K, V, ?> internalEntry2) {
return this.map.entryHelper.copy(self(), castForTesting(internalEntry), castForTesting(internalEntry2));
}
void setValueForTesting(InternalEntry<K, V, ?> internalEntry, V v) {
this.map.entryHelper.setValue(self(), castForTesting(internalEntry), v);
}
E newEntryForTesting(K k, int i, InternalEntry<K, V, ?> internalEntry) {
return this.map.entryHelper.newEntry(self(), k, i, castForTesting(internalEntry));
}
boolean removeTableEntryForTesting(InternalEntry<K, V, ?> internalEntry) {
return removeEntryForTesting(castForTesting(internalEntry));
}
E removeFromChainForTesting(InternalEntry<K, V, ?> internalEntry, InternalEntry<K, V, ?> internalEntry2) {
return removeFromChain(castForTesting(internalEntry), castForTesting(internalEntry2));
}
V getLiveValueForTesting(InternalEntry<K, V, ?> internalEntry) {
return getLiveValue(castForTesting(internalEntry));
}
void tryDrainReferenceQueues() {
if (tryLock()) {
try {
maybeDrainReferenceQueues();
} finally {
unlock();
}
}
}
/* JADX WARN: Multi-variable type inference failed */
void drainKeyReferenceQueue(ReferenceQueue<K> referenceQueue) {
int i = 0;
do {
Reference<? extends K> poll = referenceQueue.poll();
if (poll == null) {
return;
}
this.map.reclaimKey((InternalEntry) poll);
i++;
} while (i != 16);
}
void drainValueReferenceQueue(ReferenceQueue<V> referenceQueue) {
int i = 0;
do {
Reference<? extends V> poll = referenceQueue.poll();
if (poll == null) {
return;
}
this.map.reclaimValue((WeakValueReference) poll);
i++;
} while (i != 16);
}
<T> void clearReferenceQueue(ReferenceQueue<T> referenceQueue) {
do {
} while (referenceQueue.poll() != null);
}
E getFirst(int i) {
return this.table.get(i & (r0.length() - 1));
}
E getEntry(Object obj, int i) {
if (this.count == 0) {
return null;
}
for (E first = getFirst(i); first != null; first = (E) first.getNext()) {
if (first.getHash() == i) {
Object key = first.getKey();
if (key == null) {
tryDrainReferenceQueues();
} else if (this.map.keyEquivalence.equivalent(obj, key)) {
return first;
}
}
}
return null;
}
E getLiveEntry(Object obj, int i) {
return getEntry(obj, i);
}
V get(Object obj, int i) {
try {
E liveEntry = getLiveEntry(obj, i);
if (liveEntry != null) {
V v = (V) liveEntry.getValue();
if (v == null) {
tryDrainReferenceQueues();
}
return v;
}
postReadCleanup();
return null;
} finally {
postReadCleanup();
}
}
boolean containsKey(Object obj, int i) {
try {
boolean z = false;
if (this.count == 0) {
return false;
}
E liveEntry = getLiveEntry(obj, i);
if (liveEntry != null) {
if (liveEntry.getValue() != null) {
z = true;
}
}
return z;
} finally {
postReadCleanup();
}
}
/* JADX WARN: Multi-variable type inference failed */
boolean containsValue(Object obj) {
try {
if (this.count != 0) {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = atomicReferenceArray.length();
for (int i = 0; i < length; i++) {
for (E e = atomicReferenceArray.get(i); e != null; e = e.getNext()) {
Object liveValue = getLiveValue(e);
if (liveValue != null && this.map.valueEquivalence().equivalent(obj, liveValue)) {
postReadCleanup();
return true;
}
}
}
}
return false;
} finally {
postReadCleanup();
}
}
/* JADX WARN: Multi-variable type inference failed */
V put(K k, int i, V v, boolean z) {
lock();
try {
preWriteCleanup();
int i2 = this.count + 1;
if (i2 > this.threshold) {
expand();
i2 = this.count + 1;
}
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
V v2 = (V) internalEntry2.getValue();
if (v2 == null) {
this.modCount++;
setValue(internalEntry2, v);
this.count = this.count;
return null;
}
if (z) {
return v2;
}
this.modCount++;
setValue(internalEntry2, v);
return v2;
}
}
this.modCount++;
InternalEntry newEntry = this.map.entryHelper.newEntry(self(), k, i, internalEntry);
setValue(newEntry, v);
atomicReferenceArray.set(length, newEntry);
this.count = i2;
return null;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
void expand() {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = atomicReferenceArray.length();
if (length >= 1073741824) {
return;
}
int i = this.count;
C13415fZr c13415fZr = (AtomicReferenceArray<E>) newEntryArray(length << 1);
this.threshold = (c13415fZr.length() * 3) / 4;
int length2 = c13415fZr.length() - 1;
for (int i2 = 0; i2 < length; i2++) {
E e = atomicReferenceArray.get(i2);
if (e != null) {
InternalEntry next = e.getNext();
int hash = e.getHash() & length2;
if (next == null) {
c13415fZr.set(hash, e);
} else {
InternalEntry internalEntry = e;
while (next != null) {
int hash2 = next.getHash() & length2;
if (hash2 != hash) {
internalEntry = next;
hash = hash2;
}
next = next.getNext();
}
c13415fZr.set(hash, internalEntry);
while (e != internalEntry) {
int hash3 = e.getHash() & length2;
InternalEntry copyEntry = copyEntry(e, (InternalEntry) c13415fZr.get(hash3));
if (copyEntry != null) {
c13415fZr.set(hash3, copyEntry);
} else {
i--;
}
e = e.getNext();
}
}
}
}
this.table = c13415fZr;
this.count = i;
}
/* JADX WARN: Multi-variable type inference failed */
boolean replace(K k, int i, V v, V v2) {
lock();
try {
preWriteCleanup();
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
Object value = internalEntry2.getValue();
if (value == null) {
if (isCollected(internalEntry2)) {
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i2 = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i2 - 1;
}
return false;
}
if (!this.map.valueEquivalence().equivalent(v, value)) {
return false;
}
this.modCount++;
setValue(internalEntry2, v2);
return true;
}
}
return false;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
V replace(K k, int i, V v) {
lock();
try {
preWriteCleanup();
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
V v2 = (V) internalEntry2.getValue();
if (v2 == null) {
if (isCollected(internalEntry2)) {
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i2 = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i2 - 1;
}
return null;
}
this.modCount++;
setValue(internalEntry2, v);
return v2;
}
}
return null;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
V remove(Object obj, int i) {
lock();
try {
preWriteCleanup();
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(obj, key)) {
V v = (V) internalEntry2.getValue();
if (v == null && !isCollected(internalEntry2)) {
return null;
}
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i2 = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i2 - 1;
return v;
}
}
return null;
} finally {
unlock();
}
}
/* JADX WARN: Code restructure failed: missing block: B:13:0x003d, code lost:
if (r8.map.valueEquivalence().equivalent(r11, r4.getValue()) == false) goto L14;
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x003f, code lost:
r5 = true;
*/
/* JADX WARN: Code restructure failed: missing block: B:15:0x0047, code lost:
r8.modCount++;
r9 = removeFromChain(r3, r4);
r10 = r8.count;
r0.set(r1, r9);
r8.count = r10 - 1;
*/
/* JADX WARN: Code restructure failed: missing block: B:17:0x005b, code lost:
return r5;
*/
/* JADX WARN: Code restructure failed: missing block: B:21:0x0045, code lost:
if (isCollected(r4) == false) goto L19;
*/
/* JADX WARN: Code restructure failed: missing block: B:23:0x005f, code lost:
return false;
*/
/* JADX WARN: Multi-variable type inference failed */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
boolean remove(java.lang.Object r9, int r10, java.lang.Object r11) {
/*
r8 = this;
r8.lock()
r8.preWriteCleanup() // Catch: java.lang.Throwable -> L69
java.util.concurrent.atomic.AtomicReferenceArray<E extends com.google.common.collect.MapMakerInternalMap$InternalEntry<K, V, E>> r0 = r8.table // Catch: java.lang.Throwable -> L69
int r1 = r0.length() // Catch: java.lang.Throwable -> L69
r2 = 1
int r1 = r1 - r2
r1 = r1 & r10
java.lang.Object r3 = r0.get(r1) // Catch: java.lang.Throwable -> L69
com.google.common.collect.MapMakerInternalMap$InternalEntry r3 = (com.google.common.collect.MapMakerInternalMap.InternalEntry) r3 // Catch: java.lang.Throwable -> L69
r4 = r3
L16:
r5 = 0
if (r4 == 0) goto L65
java.lang.Object r6 = r4.getKey() // Catch: java.lang.Throwable -> L69
int r7 = r4.getHash() // Catch: java.lang.Throwable -> L69
if (r7 != r10) goto L60
if (r6 == 0) goto L60
com.google.common.collect.MapMakerInternalMap<K, V, E extends com.google.common.collect.MapMakerInternalMap$InternalEntry<K, V, E>, S extends com.google.common.collect.MapMakerInternalMap$Segment<K, V, E, S>> r7 = r8.map // Catch: java.lang.Throwable -> L69
com.google.common.base.Equivalence<java.lang.Object> r7 = r7.keyEquivalence // Catch: java.lang.Throwable -> L69
boolean r6 = r7.equivalent(r9, r6) // Catch: java.lang.Throwable -> L69
if (r6 == 0) goto L60
java.lang.Object r9 = r4.getValue() // Catch: java.lang.Throwable -> L69
com.google.common.collect.MapMakerInternalMap<K, V, E extends com.google.common.collect.MapMakerInternalMap$InternalEntry<K, V, E>, S extends com.google.common.collect.MapMakerInternalMap$Segment<K, V, E, S>> r10 = r8.map // Catch: java.lang.Throwable -> L69
com.google.common.base.Equivalence r10 = r10.valueEquivalence() // Catch: java.lang.Throwable -> L69
boolean r9 = r10.equivalent(r11, r9) // Catch: java.lang.Throwable -> L69
if (r9 == 0) goto L41
r5 = r2
goto L47
L41:
boolean r9 = isCollected(r4) // Catch: java.lang.Throwable -> L69
if (r9 == 0) goto L5c
L47:
int r9 = r8.modCount // Catch: java.lang.Throwable -> L69
int r9 = r9 + r2
r8.modCount = r9 // Catch: java.lang.Throwable -> L69
com.google.common.collect.MapMakerInternalMap$InternalEntry r9 = r8.removeFromChain(r3, r4) // Catch: java.lang.Throwable -> L69
int r10 = r8.count // Catch: java.lang.Throwable -> L69
r0.set(r1, r9) // Catch: java.lang.Throwable -> L69
int r10 = r10 - r2
r8.count = r10 // Catch: java.lang.Throwable -> L69
r8.unlock()
return r5
L5c:
r8.unlock()
return r5
L60:
com.google.common.collect.MapMakerInternalMap$InternalEntry r4 = r4.getNext() // Catch: java.lang.Throwable -> L69
goto L16
L65:
r8.unlock()
return r5
L69:
r9 = move-exception
r8.unlock()
throw r9
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.common.collect.MapMakerInternalMap.Segment.remove(java.lang.Object, int, java.lang.Object):boolean");
}
void clear() {
if (this.count != 0) {
lock();
try {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
for (int i = 0; i < atomicReferenceArray.length(); i++) {
atomicReferenceArray.set(i, null);
}
maybeClearReferenceQueues();
this.readCount.set(0);
this.modCount++;
this.count = 0;
} finally {
unlock();
}
}
}
E removeFromChain(E e, E e2) {
int i = this.count;
E e3 = (E) e2.getNext();
while (e != e2) {
E copyEntry = copyEntry(e, e3);
if (copyEntry != null) {
e3 = copyEntry;
} else {
i--;
}
e = (E) e.getNext();
}
this.count = i;
return e3;
}
/* JADX WARN: Multi-variable type inference failed */
boolean reclaimKey(E e, int i) {
lock();
try {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = i & (atomicReferenceArray.length() - 1);
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
if (internalEntry2 == e) {
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i2 = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i2 - 1;
return true;
}
}
unlock();
return false;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
boolean reclaimValue(K k, int i, WeakValueReference<K, V, E> weakValueReference) {
lock();
try {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
if (((WeakValueEntry) internalEntry2).getValueReference() != weakValueReference) {
return false;
}
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i2 = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i2 - 1;
return true;
}
}
return false;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
boolean clearValueForTesting(K k, int i, WeakValueReference<K, V, ? extends InternalEntry<K, V, ?>> weakValueReference) {
lock();
try {
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = (atomicReferenceArray.length() - 1) & i;
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
Object key = internalEntry2.getKey();
if (internalEntry2.getHash() == i && key != null && this.map.keyEquivalence.equivalent(k, key)) {
if (((WeakValueEntry) internalEntry2).getValueReference() != weakValueReference) {
return false;
}
atomicReferenceArray.set(length, removeFromChain(internalEntry, internalEntry2));
return true;
}
}
return false;
} finally {
unlock();
}
}
/* JADX WARN: Multi-variable type inference failed */
boolean removeEntryForTesting(E e) {
int hash = e.getHash();
AtomicReferenceArray<E> atomicReferenceArray = this.table;
int length = hash & (atomicReferenceArray.length() - 1);
InternalEntry internalEntry = (InternalEntry) atomicReferenceArray.get(length);
for (InternalEntry internalEntry2 = internalEntry; internalEntry2 != null; internalEntry2 = internalEntry2.getNext()) {
if (internalEntry2 == e) {
this.modCount++;
InternalEntry removeFromChain = removeFromChain(internalEntry, internalEntry2);
int i = this.count;
atomicReferenceArray.set(length, removeFromChain);
this.count = i - 1;
return true;
}
}
return false;
}
static <K, V, E extends InternalEntry<K, V, E>> boolean isCollected(E e) {
return e.getValue() == null;
}
V getLiveValue(E e) {
if (e.getKey() == null) {
tryDrainReferenceQueues();
return null;
}
V v = (V) e.getValue();
if (v != null) {
return v;
}
tryDrainReferenceQueues();
return null;
}
void postReadCleanup() {
if ((this.readCount.incrementAndGet() & 63) == 0) {
runCleanup();
}
}
void preWriteCleanup() {
runLockedCleanup();
}
void runCleanup() {
runLockedCleanup();
}
void runLockedCleanup() {
if (tryLock()) {
try {
maybeDrainReferenceQueues();
this.readCount.set(0);
} finally {
unlock();
}
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyStrongValueSegment<K, V> extends Segment<K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueSegment<K, V>> {
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyStrongValueSegment<K, V> self() {
return this;
}
StrongKeyStrongValueSegment(MapMakerInternalMap<K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyStrongValueEntry<K, V> castForTesting(InternalEntry<K, V, ?> internalEntry) {
return (StrongKeyStrongValueEntry) internalEntry;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyWeakValueSegment<K, V> extends Segment<K, V, StrongKeyWeakValueEntry<K, V>, StrongKeyWeakValueSegment<K, V>> {
private final ReferenceQueue<V> queueForValues;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyWeakValueSegment<K, V> self() {
return this;
}
StrongKeyWeakValueSegment(MapMakerInternalMap<K, V, StrongKeyWeakValueEntry<K, V>, StrongKeyWeakValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
this.queueForValues = new ReferenceQueue<>();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyWeakValueEntry<K, V> castForTesting(InternalEntry<K, V, ?> internalEntry) {
return (StrongKeyWeakValueEntry) internalEntry;
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakValueReference<K, V, StrongKeyWeakValueEntry<K, V>> getWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry) {
return castForTesting((InternalEntry) internalEntry).getValueReference();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakValueReference<K, V, StrongKeyWeakValueEntry<K, V>> newWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, V v) {
return new WeakValueReferenceImpl(this.queueForValues, v, castForTesting((InternalEntry) internalEntry));
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final void setWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, WeakValueReference<K, V, ? extends InternalEntry<K, V, ?>> weakValueReference) {
StrongKeyWeakValueEntry<K, V> castForTesting = castForTesting((InternalEntry) internalEntry);
WeakValueReference weakValueReference2 = ((StrongKeyWeakValueEntry) castForTesting).valueReference;
((StrongKeyWeakValueEntry) castForTesting).valueReference = weakValueReference;
weakValueReference2.clear();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeDrainReferenceQueues() {
drainValueReferenceQueue(this.queueForValues);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeClearReferenceQueues() {
clearReferenceQueue(this.queueForValues);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final ReferenceQueue<V> getValueReferenceQueueForTesting() {
return this.queueForValues;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class StrongKeyDummyValueSegment<K> extends Segment<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>, StrongKeyDummyValueSegment<K>> {
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyDummyValueSegment<K> self() {
return this;
}
StrongKeyDummyValueSegment(MapMakerInternalMap<K, MapMaker.Dummy, StrongKeyDummyValueEntry<K>, StrongKeyDummyValueSegment<K>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final StrongKeyDummyValueEntry<K> castForTesting(InternalEntry<K, MapMaker.Dummy, ?> internalEntry) {
return (StrongKeyDummyValueEntry) internalEntry;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyStrongValueSegment<K, V> extends Segment<K, V, WeakKeyStrongValueEntry<K, V>, WeakKeyStrongValueSegment<K, V>> {
private final ReferenceQueue<K> queueForKeys;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyStrongValueSegment<K, V> self() {
return this;
}
WeakKeyStrongValueSegment(MapMakerInternalMap<K, V, WeakKeyStrongValueEntry<K, V>, WeakKeyStrongValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
this.queueForKeys = new ReferenceQueue<>();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyStrongValueEntry<K, V> castForTesting(InternalEntry<K, V, ?> internalEntry) {
return (WeakKeyStrongValueEntry) internalEntry;
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeDrainReferenceQueues() {
drainKeyReferenceQueue(this.queueForKeys);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeClearReferenceQueues() {
clearReferenceQueue(this.queueForKeys);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final ReferenceQueue<K> getKeyReferenceQueueForTesting() {
return this.queueForKeys;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyWeakValueSegment<K, V> extends Segment<K, V, WeakKeyWeakValueEntry<K, V>, WeakKeyWeakValueSegment<K, V>> {
private final ReferenceQueue<K> queueForKeys;
private final ReferenceQueue<V> queueForValues;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyWeakValueSegment<K, V> self() {
return this;
}
WeakKeyWeakValueSegment(MapMakerInternalMap<K, V, WeakKeyWeakValueEntry<K, V>, WeakKeyWeakValueSegment<K, V>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
this.queueForKeys = new ReferenceQueue<>();
this.queueForValues = new ReferenceQueue<>();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyWeakValueEntry<K, V> castForTesting(InternalEntry<K, V, ?> internalEntry) {
return (WeakKeyWeakValueEntry) internalEntry;
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakValueReference<K, V, WeakKeyWeakValueEntry<K, V>> getWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry) {
return castForTesting((InternalEntry) internalEntry).getValueReference();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakValueReference<K, V, WeakKeyWeakValueEntry<K, V>> newWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, V v) {
return new WeakValueReferenceImpl(this.queueForValues, v, castForTesting((InternalEntry) internalEntry));
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final void setWeakValueReferenceForTesting(InternalEntry<K, V, ?> internalEntry, WeakValueReference<K, V, ? extends InternalEntry<K, V, ?>> weakValueReference) {
WeakKeyWeakValueEntry<K, V> castForTesting = castForTesting((InternalEntry) internalEntry);
WeakValueReference weakValueReference2 = ((WeakKeyWeakValueEntry) castForTesting).valueReference;
((WeakKeyWeakValueEntry) castForTesting).valueReference = weakValueReference;
weakValueReference2.clear();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeDrainReferenceQueues() {
drainKeyReferenceQueue(this.queueForKeys);
drainValueReferenceQueue(this.queueForValues);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeClearReferenceQueues() {
clearReferenceQueue(this.queueForKeys);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final ReferenceQueue<V> getValueReferenceQueueForTesting() {
return this.queueForValues;
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final ReferenceQueue<K> getKeyReferenceQueueForTesting() {
return this.queueForKeys;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class WeakKeyDummyValueSegment<K> extends Segment<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>, WeakKeyDummyValueSegment<K>> {
private final ReferenceQueue<K> queueForKeys;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyDummyValueSegment<K> self() {
return this;
}
WeakKeyDummyValueSegment(MapMakerInternalMap<K, MapMaker.Dummy, WeakKeyDummyValueEntry<K>, WeakKeyDummyValueSegment<K>> mapMakerInternalMap, int i, int i2) {
super(mapMakerInternalMap, i, i2);
this.queueForKeys = new ReferenceQueue<>();
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
public final WeakKeyDummyValueEntry<K> castForTesting(InternalEntry<K, MapMaker.Dummy, ?> internalEntry) {
return (WeakKeyDummyValueEntry) internalEntry;
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeDrainReferenceQueues() {
drainKeyReferenceQueue(this.queueForKeys);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final void maybeClearReferenceQueues() {
clearReferenceQueue(this.queueForKeys);
}
@Override // com.google.common.collect.MapMakerInternalMap.Segment
final ReferenceQueue<K> getKeyReferenceQueueForTesting() {
return this.queueForKeys;
}
}
/* loaded from: classes2.dex */
static final class CleanupMapTask implements Runnable {
final WeakReference<MapMakerInternalMap<?, ?, ?, ?>> mapReference;
public CleanupMapTask(MapMakerInternalMap<?, ?, ?, ?> mapMakerInternalMap) {
this.mapReference = new WeakReference<>(mapMakerInternalMap);
}
@Override // java.lang.Runnable
public final void run() {
MapMakerInternalMap<?, ?, ?, ?> mapMakerInternalMap = this.mapReference.get();
if (mapMakerInternalMap == null) {
throw new CancellationException();
}
for (Segment<?, ?, ?, ?> segment : mapMakerInternalMap.segments) {
segment.runCleanup();
}
}
}
Strength keyStrength() {
return this.entryHelper.keyStrength();
}
Strength valueStrength() {
return this.entryHelper.valueStrength();
}
Equivalence<Object> valueEquivalence() {
return this.entryHelper.valueStrength().defaultEquivalence();
}
@Override // java.util.AbstractMap, java.util.Map
public boolean isEmpty() {
Segment<K, V, E, S>[] segmentArr = this.segments;
long j = 0;
for (int i = 0; i < segmentArr.length; i++) {
if (segmentArr[i].count != 0) {
return false;
}
j += segmentArr[i].modCount;
}
if (j == 0) {
return true;
}
for (int i2 = 0; i2 < segmentArr.length; i2++) {
if (segmentArr[i2].count != 0) {
return false;
}
j -= segmentArr[i2].modCount;
}
return j == 0;
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
long j = 0;
for (int i = 0; i < this.segments.length; i++) {
j += r0[i].count;
}
return Ints.saturatedCast(j);
}
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
if (obj == null) {
return null;
}
int hash = hash(obj);
return segmentFor(hash).get(obj, hash);
}
/* JADX INFO: Access modifiers changed from: package-private */
public E getEntry(Object obj) {
if (obj == null) {
return null;
}
int hash = hash(obj);
return segmentFor(hash).getEntry(obj, hash);
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
if (obj == null) {
return false;
}
int hash = hash(obj);
return segmentFor(hash).containsKey(obj, hash);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r10v0 */
/* JADX WARN: Type inference failed for: r10v1, types: [int] */
/* JADX WARN: Type inference failed for: r10v3 */
/* JADX WARN: Type inference failed for: r11v0, types: [com.google.common.collect.MapMakerInternalMap$Segment] */
/* JADX WARN: Type inference failed for: r13v0 */
/* JADX WARN: Type inference failed for: r13v1, types: [int] */
/* JADX WARN: Type inference failed for: r13v3 */
/* JADX WARN: Type inference failed for: r3v0, types: [com.google.common.collect.MapMakerInternalMap$Segment<K, V, E extends com.google.common.collect.MapMakerInternalMap$InternalEntry<K, V, E>, S extends com.google.common.collect.MapMakerInternalMap$Segment<K, V, E, S>>[]] */
@Override // java.util.AbstractMap, java.util.Map
public boolean containsValue(Object obj) {
boolean z = false;
if (obj == null) {
return false;
}
Segment<K, V, E, S>[] segmentArr = this.segments;
long j = -1;
int i = 0;
while (i < 3) {
int length = segmentArr.length;
long j2 = 0;
for (?? r10 = z; r10 < length; r10++) {
?? r11 = segmentArr[r10];
int i2 = r11.count;
AtomicReferenceArray<E> atomicReferenceArray = r11.table;
for (?? r13 = z; r13 < atomicReferenceArray.length(); r13++) {
for (E e = atomicReferenceArray.get(r13); e != null; e = e.getNext()) {
Object liveValue = r11.getLiveValue(e);
if (liveValue != null && valueEquivalence().equivalent(obj, liveValue)) {
return true;
}
}
}
j2 += r11.modCount;
z = false;
}
if (j2 == j) {
return false;
}
i++;
j = j2;
z = false;
}
return z;
}
@Override // java.util.AbstractMap, java.util.Map
public V put(K k, V v) {
Preconditions.checkNotNull(k);
Preconditions.checkNotNull(v);
int hash = hash(k);
return segmentFor(hash).put(k, hash, v, false);
}
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
public V putIfAbsent(K k, V v) {
Preconditions.checkNotNull(k);
Preconditions.checkNotNull(v);
int hash = hash(k);
return segmentFor(hash).put(k, hash, v, true);
}
@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()) {
put(entry.getKey(), entry.getValue());
}
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
if (obj == null) {
return null;
}
int hash = hash(obj);
return segmentFor(hash).remove(obj, hash);
}
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
public boolean remove(Object obj, Object obj2) {
if (obj == null || obj2 == null) {
return false;
}
int hash = hash(obj);
return segmentFor(hash).remove(obj, hash, obj2);
}
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
public boolean replace(K k, V v, V v2) {
Preconditions.checkNotNull(k);
Preconditions.checkNotNull(v2);
if (v == null) {
return false;
}
int hash = hash(k);
return segmentFor(hash).replace(k, hash, v, v2);
}
@Override // java.util.Map, java.util.concurrent.ConcurrentMap
public V replace(K k, V v) {
Preconditions.checkNotNull(k);
Preconditions.checkNotNull(v);
int hash = hash(k);
return segmentFor(hash).replace(k, hash, v);
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
for (Segment<K, V, E, S> segment : this.segments) {
segment.clear();
}
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
Set<K> set = this.keySet;
if (set != null) {
return set;
}
KeySet keySet = new KeySet(this);
this.keySet = keySet;
return keySet;
}
@Override // java.util.AbstractMap, java.util.Map
public Collection<V> values() {
Collection<V> collection = this.values;
if (collection != null) {
return collection;
}
Values values = new Values(this);
this.values = values;
return values;
}
@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;
}
EntrySet entrySet = new EntrySet(this);
this.entrySet = entrySet;
return entrySet;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public abstract class HashIterator<T> implements Iterator<T> {
Segment<K, V, E, S> currentSegment;
AtomicReferenceArray<E> currentTable;
MapMakerInternalMap<K, V, E, S>.WriteThroughEntry lastReturned;
E nextEntry;
MapMakerInternalMap<K, V, E, S>.WriteThroughEntry nextExternal;
int nextSegmentIndex;
int nextTableIndex = -1;
final MapMakerInternalMap this$0;
@Override // java.util.Iterator
public abstract T next();
HashIterator(MapMakerInternalMap mapMakerInternalMap) {
this.this$0 = mapMakerInternalMap;
this.nextSegmentIndex = mapMakerInternalMap.segments.length - 1;
advance();
}
final void advance() {
this.nextExternal = null;
if (nextInChain() || nextInTable()) {
return;
}
while (this.nextSegmentIndex >= 0) {
Segment<K, V, E, S>[] segmentArr = this.this$0.segments;
int i = this.nextSegmentIndex;
this.nextSegmentIndex = i - 1;
Segment<K, V, E, S> segment = segmentArr[i];
this.currentSegment = segment;
if (segment.count != 0) {
this.currentTable = this.currentSegment.table;
this.nextTableIndex = r0.length() - 1;
if (nextInTable()) {
return;
}
}
}
}
boolean nextInChain() {
E e = this.nextEntry;
if (e == null) {
return false;
}
while (true) {
E e2 = (E) e.getNext();
this.nextEntry = e2;
if (e2 == null) {
return false;
}
if (advanceTo(e2)) {
return true;
}
e = this.nextEntry;
}
}
boolean nextInTable() {
while (true) {
int i = this.nextTableIndex;
if (i < 0) {
return false;
}
AtomicReferenceArray<E> atomicReferenceArray = this.currentTable;
this.nextTableIndex = i - 1;
E e = atomicReferenceArray.get(i);
this.nextEntry = e;
if (e != null && (advanceTo(e) || nextInChain())) {
return true;
}
}
}
boolean advanceTo(E e) {
try {
Object key = e.getKey();
Object liveValue = this.this$0.getLiveValue(e);
if (liveValue == null) {
this.currentSegment.postReadCleanup();
return false;
}
this.nextExternal = new WriteThroughEntry(this.this$0, key, liveValue);
this.currentSegment.postReadCleanup();
return true;
} catch (Throwable th) {
this.currentSegment.postReadCleanup();
throw th;
}
}
MapMakerInternalMap<K, V, E, S>.WriteThroughEntry nextEntry() {
MapMakerInternalMap<K, V, E, S>.WriteThroughEntry writeThroughEntry = this.nextExternal;
if (writeThroughEntry == null) {
throw new NoSuchElementException();
}
this.lastReturned = writeThroughEntry;
advance();
return this.lastReturned;
}
@Override // java.util.Iterator
public void remove() {
CollectPreconditions.checkRemove(this.lastReturned != null);
this.this$0.remove(this.lastReturned.getKey());
this.lastReturned = null;
}
@Override // java.util.Iterator
public boolean hasNext() {
return this.nextExternal != null;
}
}
/* loaded from: classes2.dex */
final class KeyIterator extends HashIterator {
KeyIterator(MapMakerInternalMap mapMakerInternalMap) {
super(mapMakerInternalMap);
}
@Override // com.google.common.collect.MapMakerInternalMap.HashIterator, java.util.Iterator
public final K next() {
return nextEntry().getKey();
}
}
/* loaded from: classes2.dex */
final class ValueIterator extends HashIterator {
ValueIterator(MapMakerInternalMap mapMakerInternalMap) {
super(mapMakerInternalMap);
}
@Override // com.google.common.collect.MapMakerInternalMap.HashIterator, java.util.Iterator
public final V next() {
return nextEntry().getValue();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class WriteThroughEntry extends AbstractMapEntry<K, V> {
final K key;
final MapMakerInternalMap this$0;
V value;
WriteThroughEntry(MapMakerInternalMap mapMakerInternalMap, K k, V v) {
this.this$0 = mapMakerInternalMap;
this.key = k;
this.value = v;
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public final boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return this.key.equals(entry.getKey()) && this.value.equals(entry.getValue());
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public final int hashCode() {
return this.key.hashCode() ^ this.value.hashCode();
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public final V setValue(V v) {
V put = this.this$0.put(this.key, v);
this.value = v;
return put;
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public final V getValue() {
return this.value;
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public final K getKey() {
return this.key;
}
}
/* loaded from: classes2.dex */
final class EntryIterator extends HashIterator {
EntryIterator(MapMakerInternalMap mapMakerInternalMap) {
super(mapMakerInternalMap);
}
@Override // com.google.common.collect.MapMakerInternalMap.HashIterator, java.util.Iterator
public final Map.Entry<K, V> next() {
return nextEntry();
}
}
/* loaded from: classes2.dex */
final class KeySet extends SafeToArraySet<K> {
final MapMakerInternalMap this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
KeySet(MapMakerInternalMap mapMakerInternalMap) {
super();
this.this$0 = mapMakerInternalMap;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<K> iterator() {
return new KeyIterator(this.this$0);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.this$0.size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean isEmpty() {
return this.this$0.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return this.this$0.containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
return this.this$0.remove(obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final void clear() {
this.this$0.clear();
}
}
/* loaded from: classes2.dex */
final class Values extends AbstractCollection<V> {
final MapMakerInternalMap this$0;
Values(MapMakerInternalMap mapMakerInternalMap) {
this.this$0 = mapMakerInternalMap;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final Iterator<V> iterator() {
return new ValueIterator(this.this$0);
}
@Override // java.util.AbstractCollection, java.util.Collection
public final int size() {
return this.this$0.size();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean isEmpty() {
return this.this$0.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final boolean contains(Object obj) {
return this.this$0.containsValue(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection
public final void clear() {
this.this$0.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final Object[] toArray() {
return MapMakerInternalMap.toArrayList(this).toArray();
}
@Override // java.util.AbstractCollection, java.util.Collection
public final <T> T[] toArray(T[] tArr) {
return (T[]) MapMakerInternalMap.toArrayList(this).toArray(tArr);
}
}
/* loaded from: classes2.dex */
final class EntrySet extends SafeToArraySet<Map.Entry<K, V>> {
final MapMakerInternalMap this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
EntrySet(MapMakerInternalMap mapMakerInternalMap) {
super();
this.this$0 = mapMakerInternalMap;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<Map.Entry<K, V>> iterator() {
return new EntryIterator(this.this$0);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
Map.Entry entry;
Object key;
V v;
return (obj instanceof Map.Entry) && (key = (entry = (Map.Entry) obj).getKey()) != null && (v = this.this$0.get(key)) != null && this.this$0.valueEquivalence().equivalent(entry.getValue(), v);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
Map.Entry entry;
Object key;
return (obj instanceof Map.Entry) && (key = (entry = (Map.Entry) obj).getKey()) != null && this.this$0.remove(key, entry.getValue());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.this$0.size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean isEmpty() {
return this.this$0.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final void clear() {
this.this$0.clear();
}
}
/* loaded from: classes2.dex */
static abstract class SafeToArraySet<E> extends AbstractSet<E> {
private SafeToArraySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public Object[] toArray() {
return MapMakerInternalMap.toArrayList(this).toArray();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public <T> T[] toArray(T[] tArr) {
return (T[]) MapMakerInternalMap.toArrayList(this).toArray(tArr);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static <E> ArrayList<E> toArrayList(Collection<E> collection) {
ArrayList<E> arrayList = new ArrayList<>(collection.size());
Iterators.addAll(arrayList, collection.iterator());
return arrayList;
}
Object writeReplace() {
return new SerializationProxy(this.entryHelper.keyStrength(), this.entryHelper.valueStrength(), this.keyEquivalence, this.entryHelper.valueStrength().defaultEquivalence(), this.concurrencyLevel, this);
}
/* loaded from: classes2.dex */
static abstract class AbstractSerializationProxy<K, V> extends ForwardingConcurrentMap<K, V> implements Serializable {
private static final long serialVersionUID = 3;
final int concurrencyLevel;
transient ConcurrentMap<K, V> delegate;
final Equivalence<Object> keyEquivalence;
final Strength keyStrength;
final Equivalence<Object> valueEquivalence;
final Strength valueStrength;
AbstractSerializationProxy(Strength strength, Strength strength2, Equivalence<Object> equivalence, Equivalence<Object> equivalence2, int i, ConcurrentMap<K, V> concurrentMap) {
this.keyStrength = strength;
this.valueStrength = strength2;
this.keyEquivalence = equivalence;
this.valueEquivalence = equivalence2;
this.concurrencyLevel = i;
this.delegate = concurrentMap;
}
void writeMapTo(ObjectOutputStream objectOutputStream) throws IOException {
objectOutputStream.writeInt(this.delegate.size());
for (Map.Entry<K, V> entry : this.delegate.entrySet()) {
objectOutputStream.writeObject(entry.getKey());
objectOutputStream.writeObject(entry.getValue());
}
objectOutputStream.writeObject(null);
}
MapMaker readMapMaker(ObjectInputStream objectInputStream) throws IOException {
return new MapMaker().initialCapacity(objectInputStream.readInt()).setKeyStrength(this.keyStrength).setValueStrength(this.valueStrength).keyEquivalence(this.keyEquivalence).concurrencyLevel(this.concurrencyLevel);
}
/* JADX WARN: Multi-variable type inference failed */
void readEntries(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
while (true) {
Object readObject = objectInputStream.readObject();
if (readObject == null) {
return;
}
this.delegate.put(readObject, objectInputStream.readObject());
}
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingConcurrentMap, com.google.common.collect.ForwardingMap, com.google.common.collect.ForwardingObject
public ConcurrentMap<K, V> delegate() {
return this.delegate;
}
}
/* loaded from: classes2.dex */
static final class SerializationProxy<K, V> extends AbstractSerializationProxy<K, V> {
private static final long serialVersionUID = 3;
SerializationProxy(Strength strength, Strength strength2, Equivalence<Object> equivalence, Equivalence<Object> equivalence2, int i, ConcurrentMap<K, V> concurrentMap) {
super(strength, strength2, equivalence, equivalence2, i, concurrentMap);
}
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
objectOutputStream.defaultWriteObject();
writeMapTo(objectOutputStream);
}
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
objectInputStream.defaultReadObject();
this.delegate = readMapMaker(objectInputStream).makeMap();
readEntries(objectInputStream);
}
private Object readResolve() {
return this.delegate;
}
}
static <K, V, E extends InternalEntry<K, V, E>> WeakValueReference<K, V, E> unsetWeakValueReference() {
return (WeakValueReference<K, V, E>) UNSET_WEAK_VALUE_REFERENCE;
}
}