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

456 lines
17 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.google.common.base.Preconditions;
import com.huawei.hms.framework.common.ContainerUtils;
import java.util.AbstractMap;
import java.util.Iterator;
import java.util.Map;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
private static final byte ABSENT = -1;
private static final int BYTE_MASK = 255;
private static final int BYTE_MAX_SIZE = 128;
static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap(null, new Object[0], 0);
private static final int SHORT_MASK = 65535;
private static final int SHORT_MAX_SIZE = 32768;
private static final long serialVersionUID = 0;
final transient Object[] alternatingKeysAndValues;
private final transient Object hashTable;
private final transient int size;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableMap
public final boolean isPartialView() {
return false;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <K, V> RegularImmutableMap<K, V> create(int i, Object[] objArr) {
if (i == 0) {
return (RegularImmutableMap) EMPTY;
}
if (i == 1) {
CollectPreconditions.checkEntryNotNull(objArr[0], objArr[1]);
return new RegularImmutableMap<>(null, objArr, 1);
}
Preconditions.checkPositionIndex(i, objArr.length >> 1);
return new RegularImmutableMap<>(createHashTable(objArr, i, ImmutableSet.chooseTableSize(i), 0), objArr, i);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Code restructure failed: missing block: B:20:0x0039, code lost:
r11[r5] = (byte) r1;
r2 = r2 + 1;
*/
/* JADX WARN: Code restructure failed: missing block: B:37:0x0079, code lost:
r11[r5] = (short) r1;
r2 = r2 + 1;
*/
/* JADX WARN: Code restructure failed: missing block: B:52:0x00b0, code lost:
r11[r6] = r1;
r2 = r2 + 1;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static java.lang.Object createHashTable(java.lang.Object[] r9, int r10, int r11, int r12) {
/*
r0 = 1
if (r10 != r0) goto Le
r10 = r9[r12]
r11 = r12 ^ 1
r9 = r9[r11]
com.google.common.collect.CollectPreconditions.checkEntryNotNull(r10, r9)
r9 = 0
return r9
Le:
int r0 = r11 + (-1)
r1 = 128(0x80, float:1.8E-43)
r2 = 0
r3 = -1
if (r11 > r1) goto L50
byte[] r11 = new byte[r11]
java.util.Arrays.fill(r11, r3)
L1b:
if (r2 >= r10) goto L4f
int r1 = r2 << 1
int r1 = r1 + r12
r3 = r9[r1]
r4 = r1 ^ 1
r4 = r9[r4]
com.google.common.collect.CollectPreconditions.checkEntryNotNull(r3, r4)
int r5 = r3.hashCode()
int r5 = com.google.common.collect.Hashing.smear(r5)
L31:
r5 = r5 & r0
r6 = r11[r5]
r7 = 255(0xff, float:3.57E-43)
r6 = r6 & r7
if (r6 != r7) goto L3f
byte r1 = (byte) r1
r11[r5] = r1
int r2 = r2 + 1
goto L1b
L3f:
r7 = r9[r6]
boolean r7 = r7.equals(r3)
if (r7 != 0) goto L4a
int r5 = r5 + 1
goto L31
L4a:
java.lang.IllegalArgumentException r9 = duplicateKeyException(r3, r4, r9, r6)
throw r9
L4f:
return r11
L50:
r1 = 32768(0x8000, float:4.5918E-41)
if (r11 > r1) goto L90
short[] r11 = new short[r11]
java.util.Arrays.fill(r11, r3)
L5a:
if (r2 >= r10) goto L8f
int r1 = r2 << 1
int r1 = r1 + r12
r3 = r9[r1]
r4 = r1 ^ 1
r4 = r9[r4]
com.google.common.collect.CollectPreconditions.checkEntryNotNull(r3, r4)
int r5 = r3.hashCode()
int r5 = com.google.common.collect.Hashing.smear(r5)
L70:
r5 = r5 & r0
short r6 = r11[r5]
r7 = 65535(0xffff, float:9.1834E-41)
r6 = r6 & r7
if (r6 != r7) goto L7f
short r1 = (short) r1
r11[r5] = r1
int r2 = r2 + 1
goto L5a
L7f:
r7 = r9[r6]
boolean r7 = r7.equals(r3)
if (r7 != 0) goto L8a
int r5 = r5 + 1
goto L70
L8a:
java.lang.IllegalArgumentException r9 = duplicateKeyException(r3, r4, r9, r6)
throw r9
L8f:
return r11
L90:
int[] r11 = new int[r11]
java.util.Arrays.fill(r11, r3)
L95:
if (r2 >= r10) goto Lc5
int r1 = r2 << 1
int r1 = r1 + r12
r4 = r9[r1]
r5 = r1 ^ 1
r5 = r9[r5]
com.google.common.collect.CollectPreconditions.checkEntryNotNull(r4, r5)
int r6 = r4.hashCode()
int r6 = com.google.common.collect.Hashing.smear(r6)
Lab:
r6 = r6 & r0
r7 = r11[r6]
if (r7 != r3) goto Lb5
r11[r6] = r1
int r2 = r2 + 1
goto L95
Lb5:
r8 = r9[r7]
boolean r8 = r8.equals(r4)
if (r8 != 0) goto Lc0
int r6 = r6 + 1
goto Lab
Lc0:
java.lang.IllegalArgumentException r9 = duplicateKeyException(r4, r5, r9, r7)
throw r9
Lc5:
return r11
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.common.collect.RegularImmutableMap.createHashTable(java.lang.Object[], int, int, int):java.lang.Object");
}
private static IllegalArgumentException duplicateKeyException(Object obj, Object obj2, Object[] objArr, int i) {
String valueOf = String.valueOf(obj);
String valueOf2 = String.valueOf(obj2);
String valueOf3 = String.valueOf(objArr[i]);
String valueOf4 = String.valueOf(objArr[i ^ 1]);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 39 + String.valueOf(valueOf2).length() + String.valueOf(valueOf3).length() + String.valueOf(valueOf4).length());
sb.append("Multiple entries with same key: ");
sb.append(valueOf);
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
sb.append(valueOf2);
sb.append(" and ");
sb.append(valueOf3);
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
sb.append(valueOf4);
return new IllegalArgumentException(sb.toString());
}
private RegularImmutableMap(Object obj, Object[] objArr, int i) {
this.hashTable = obj;
this.alternatingKeysAndValues = objArr;
this.size = i;
}
@Override // com.google.common.collect.ImmutableMap, java.util.Map
public final V get(Object obj) {
return (V) get(this.hashTable, this.alternatingKeysAndValues, this.size, 0, obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static Object get(Object obj, Object[] objArr, int i, int i2, Object obj2) {
if (obj2 == null) {
return null;
}
if (i == 1) {
if (objArr[i2].equals(obj2)) {
return objArr[i2 ^ 1];
}
return null;
}
if (obj == null) {
return null;
}
if (obj instanceof byte[]) {
byte[] bArr = (byte[]) obj;
int length = bArr.length;
int smear = Hashing.smear(obj2.hashCode());
while (true) {
int i3 = smear & (length - 1);
int i4 = bArr[i3] & 255;
if (i4 == 255) {
return null;
}
if (objArr[i4].equals(obj2)) {
return objArr[i4 ^ 1];
}
smear = i3 + 1;
}
} else if (obj instanceof short[]) {
short[] sArr = (short[]) obj;
int length2 = sArr.length;
int smear2 = Hashing.smear(obj2.hashCode());
while (true) {
int i5 = smear2 & (length2 - 1);
int i6 = sArr[i5] & 65535;
if (i6 == 65535) {
return null;
}
if (objArr[i6].equals(obj2)) {
return objArr[i6 ^ 1];
}
smear2 = i5 + 1;
}
} else {
int[] iArr = (int[]) obj;
int length3 = iArr.length;
int smear3 = Hashing.smear(obj2.hashCode());
while (true) {
int i7 = smear3 & (length3 - 1);
int i8 = iArr[i7];
if (i8 == -1) {
return null;
}
if (objArr[i8].equals(obj2)) {
return objArr[i8 ^ 1];
}
smear3 = i7 + 1;
}
}
}
@Override // com.google.common.collect.ImmutableMap
final ImmutableSet<Map.Entry<K, V>> createEntrySet() {
return new EntrySet(this, this.alternatingKeysAndValues, 0, this.size);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class EntrySet<K, V> extends ImmutableSet<Map.Entry<K, V>> {
private final transient Object[] alternatingKeysAndValues;
private final transient int keyOffset;
private final transient ImmutableMap<K, V> map;
private final transient int size;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public boolean isPartialView() {
return true;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public /* bridge */ /* synthetic */ Iterator iterator() {
return iterator();
}
/* JADX INFO: Access modifiers changed from: package-private */
public EntrySet(ImmutableMap<K, V> immutableMap, Object[] objArr, int i, int i2) {
this.map = immutableMap;
this.alternatingKeysAndValues = objArr;
this.keyOffset = i;
this.size = i2;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public UnmodifiableIterator<Map.Entry<K, V>> iterator() {
return asList().iterator();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public int copyIntoArray(Object[] objArr, int i) {
return asList().copyIntoArray(objArr, i);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableSet
public ImmutableList<Map.Entry<K, V>> createAsList() {
return new ImmutableList<Map.Entry<K, V>>(this) { // from class: com.google.common.collect.RegularImmutableMap.EntrySet.1
final EntrySet this$0;
@Override // com.google.common.collect.ImmutableCollection
public boolean isPartialView() {
return true;
}
{
this.this$0 = this;
}
@Override // java.util.List
public Map.Entry<K, V> get(int i) {
Preconditions.checkElementIndex(i, this.this$0.size);
int i2 = i << 1;
return new AbstractMap.SimpleImmutableEntry(this.this$0.alternatingKeysAndValues[this.this$0.keyOffset + i2], this.this$0.alternatingKeysAndValues[i2 + (this.this$0.keyOffset ^ 1)]);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public int size() {
return this.this$0.size;
}
};
}
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
Object key = entry.getKey();
Object value = entry.getValue();
return value != null && value.equals(this.map.get(key));
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return this.size;
}
}
@Override // com.google.common.collect.ImmutableMap
final ImmutableSet<K> createKeySet() {
return new KeySet(this, new KeysOrValuesAsList(this.alternatingKeysAndValues, 0, this.size));
}
/* loaded from: classes2.dex */
static final class KeysOrValuesAsList extends ImmutableList<Object> {
private final transient Object[] alternatingKeysAndValues;
private final transient int offset;
private final transient int size;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public final boolean isPartialView() {
return true;
}
/* JADX INFO: Access modifiers changed from: package-private */
public KeysOrValuesAsList(Object[] objArr, int i, int i2) {
this.alternatingKeysAndValues = objArr;
this.offset = i;
this.size = i2;
}
@Override // java.util.List
public final Object get(int i) {
Preconditions.checkElementIndex(i, this.size);
return this.alternatingKeysAndValues[(i << 1) + this.offset];
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
public final int size() {
return this.size;
}
}
/* loaded from: classes2.dex */
static final class KeySet<K> extends ImmutableSet<K> {
private final transient ImmutableList<K> list;
private final transient ImmutableMap<K, ?> map;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public final boolean isPartialView() {
return true;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public final /* bridge */ /* synthetic */ Iterator iterator() {
return iterator();
}
/* JADX INFO: Access modifiers changed from: package-private */
public KeySet(ImmutableMap<K, ?> immutableMap, ImmutableList<K> immutableList) {
this.map = immutableMap;
this.list = immutableList;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public final UnmodifiableIterator<K> iterator() {
return asList().iterator();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public final int copyIntoArray(Object[] objArr, int i) {
return asList().copyIntoArray(objArr, i);
}
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return this.map.get(obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.map.size();
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection
public final ImmutableList<K> asList() {
return this.list;
}
}
@Override // com.google.common.collect.ImmutableMap
final ImmutableCollection<V> createValues() {
return new KeysOrValuesAsList(this.alternatingKeysAndValues, 1, this.size);
}
@Override // java.util.Map
public final int size() {
return this.size;
}
}