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

161 lines
4.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import io.flutter.embedding.android.KeyboardMap;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class CompactLinkedHashMap<K, V> extends CompactHashMap<K, V> {
private static final int ENDPOINT = -2;
private final boolean accessOrder;
private transient int firstEntry;
private transient int lastEntry;
transient long[] links;
public static <K, V> CompactLinkedHashMap<K, V> create() {
return new CompactLinkedHashMap<>();
}
public static <K, V> CompactLinkedHashMap<K, V> createWithExpectedSize(int i) {
return new CompactLinkedHashMap<>(i);
}
CompactLinkedHashMap() {
this(3);
}
CompactLinkedHashMap(int i) {
this(i, false);
}
CompactLinkedHashMap(int i, boolean z) {
super(i);
this.accessOrder = z;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public void init(int i) {
super.init(i);
this.firstEntry = -2;
this.lastEntry = -2;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public int allocArrays() {
int allocArrays = super.allocArrays();
this.links = new long[allocArrays];
return allocArrays;
}
@Override // com.google.common.collect.CompactHashMap
Map<K, V> createHashFloodingResistantDelegate(int i) {
return new LinkedHashMap(i, 1.0f, this.accessOrder);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public Map<K, V> convertToHashFloodingResistantImplementation() {
Map<K, V> convertToHashFloodingResistantImplementation = super.convertToHashFloodingResistantImplementation();
this.links = null;
return convertToHashFloodingResistantImplementation;
}
private int getPredecessor(int i) {
return ((int) (this.links[i] >>> 32)) - 1;
}
@Override // com.google.common.collect.CompactHashMap
int getSuccessor(int i) {
return ((int) this.links[i]) - 1;
}
private void setSuccessor(int i, int i2) {
long[] jArr = this.links;
jArr[i] = (jArr[i] & (-4294967296L)) | ((i2 + 1) & KeyboardMap.kValueMask);
}
private void setPredecessor(int i, int i2) {
long[] jArr = this.links;
jArr[i] = (jArr[i] & KeyboardMap.kValueMask) | ((i2 + 1) << 32);
}
private void setSucceeds(int i, int i2) {
if (i == -2) {
this.firstEntry = i2;
} else {
setSuccessor(i, i2);
}
if (i2 == -2) {
this.lastEntry = i;
} else {
setPredecessor(i2, i);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public void insertEntry(int i, K k, V v, int i2, int i3) {
super.insertEntry(i, k, v, i2, i3);
setSucceeds(this.lastEntry, i);
setSucceeds(i, -2);
}
@Override // com.google.common.collect.CompactHashMap
void accessEntry(int i) {
if (this.accessOrder) {
setSucceeds(getPredecessor(i), getSuccessor(i));
setSucceeds(this.lastEntry, i);
setSucceeds(i, -2);
incrementModCount();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public void moveLastEntry(int i, int i2) {
int size = size() - 1;
super.moveLastEntry(i, i2);
setSucceeds(getPredecessor(i), getSuccessor(i));
if (i < size) {
setSucceeds(getPredecessor(size), i);
setSucceeds(i, getSuccessor(size));
}
this.links[size] = 0;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.CompactHashMap
public void resizeEntries(int i) {
super.resizeEntries(i);
this.links = Arrays.copyOf(this.links, i);
}
@Override // com.google.common.collect.CompactHashMap
int adjustAfterRemove(int i, int i2) {
return i >= size() ? i2 : i;
}
@Override // com.google.common.collect.CompactHashMap, java.util.AbstractMap, java.util.Map
public void clear() {
if (needsAllocArrays()) {
return;
}
this.firstEntry = -2;
this.lastEntry = -2;
long[] jArr = this.links;
if (jArr != null) {
Arrays.fill(jArr, 0, size(), 0L);
}
super.clear();
}
@Override // com.google.common.collect.CompactHashMap
int firstEntryIndex() {
return this.firstEntry;
}
}