what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzwh.java

274 lines
8.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import java.lang.Comparable;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class zzwh<K extends Comparable<K>, V> extends AbstractMap<K, V> {
private boolean zzbll;
private final int zzbry;
private List<zzwo> zzbrz;
private Map<K, V> zzbsa;
private volatile zzwq zzbsb;
private Map<K, V> zzbsc;
private volatile zzwk zzbsd;
/* JADX INFO: Access modifiers changed from: package-private */
public static <FieldDescriptorType extends zzty<FieldDescriptorType>> zzwh<FieldDescriptorType, Object> zzdo(int i) {
return new zzwi(i);
}
private zzwh(int i) {
this.zzbry = i;
this.zzbrz = Collections.emptyList();
this.zzbsa = Collections.emptyMap();
this.zzbsc = Collections.emptyMap();
}
public void zzpt() {
Map<K, V> unmodifiableMap;
Map<K, V> unmodifiableMap2;
if (this.zzbll) {
return;
}
if (this.zzbsa.isEmpty()) {
unmodifiableMap = Collections.emptyMap();
} else {
unmodifiableMap = Collections.unmodifiableMap(this.zzbsa);
}
this.zzbsa = unmodifiableMap;
if (this.zzbsc.isEmpty()) {
unmodifiableMap2 = Collections.emptyMap();
} else {
unmodifiableMap2 = Collections.unmodifiableMap(this.zzbsc);
}
this.zzbsc = unmodifiableMap2;
this.zzbll = true;
}
public final int zzsx() {
return this.zzbrz.size();
}
public final Map.Entry<K, V> zzdp(int i) {
return this.zzbrz.get(i);
}
public final Iterable<Map.Entry<K, V>> zzsy() {
if (this.zzbsa.isEmpty()) {
return zzwl.zztd();
}
return this.zzbsa.entrySet();
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return this.zzbrz.size() + this.zzbsa.size();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
Comparable comparable = (Comparable) obj;
return zza((zzwh<K, V>) comparable) >= 0 || this.zzbsa.containsKey(comparable);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
Comparable comparable = (Comparable) obj;
int zza = zza((zzwh<K, V>) comparable);
if (zza >= 0) {
return (V) this.zzbrz.get(zza).getValue();
}
return this.zzbsa.get(comparable);
}
/* JADX WARN: Multi-variable type inference failed */
public final V zza(K k, V v) {
zzta();
int zza = zza((zzwh<K, V>) k);
if (zza >= 0) {
return (V) this.zzbrz.get(zza).setValue(v);
}
zzta();
if (this.zzbrz.isEmpty() && !(this.zzbrz instanceof ArrayList)) {
this.zzbrz = new ArrayList(this.zzbry);
}
int i = -(zza + 1);
if (i >= this.zzbry) {
return zztb().put(k, v);
}
int size = this.zzbrz.size();
int i2 = this.zzbry;
if (size == i2) {
zzwo remove = this.zzbrz.remove(i2 - 1);
zztb().put((Comparable) remove.getKey(), remove.getValue());
}
this.zzbrz.add(i, new zzwo(this, k, v));
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
zzta();
if (!this.zzbrz.isEmpty()) {
this.zzbrz.clear();
}
if (this.zzbsa.isEmpty()) {
return;
}
this.zzbsa.clear();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
zzta();
Comparable comparable = (Comparable) obj;
int zza = zza((zzwh<K, V>) comparable);
if (zza >= 0) {
return (V) zzdq(zza);
}
if (this.zzbsa.isEmpty()) {
return null;
}
return this.zzbsa.remove(comparable);
}
/* JADX INFO: Access modifiers changed from: private */
public final V zzdq(int i) {
zzta();
V v = (V) this.zzbrz.remove(i).getValue();
if (!this.zzbsa.isEmpty()) {
Iterator<Map.Entry<K, V>> it = zztb().entrySet().iterator();
this.zzbrz.add(new zzwo(this, it.next()));
it.remove();
}
return v;
}
private final int zza(K k) {
int size = this.zzbrz.size();
int i = size - 1;
if (i >= 0) {
int compareTo = k.compareTo((Comparable) this.zzbrz.get(i).getKey());
if (compareTo <= 0) {
if (compareTo == 0) {
return i;
}
}
return -(size + 1);
}
size = 0;
while (size <= i) {
int i2 = (size + i) / 2;
int compareTo2 = k.compareTo((Comparable) this.zzbrz.get(i2).getKey());
if (compareTo2 < 0) {
i = i2 - 1;
} else {
if (compareTo2 <= 0) {
return i2;
}
size = i2 + 1;
}
}
return -(size + 1);
}
@Override // java.util.AbstractMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
if (this.zzbsb == null) {
this.zzbsb = new zzwq(this, null);
}
return this.zzbsb;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final Set<Map.Entry<K, V>> zzsz() {
if (this.zzbsd == null) {
this.zzbsd = new zzwk(this, null);
}
return this.zzbsd;
}
/* JADX INFO: Access modifiers changed from: private */
public final void zzta() {
if (this.zzbll) {
throw new UnsupportedOperationException();
}
}
private final SortedMap<K, V> zztb() {
zzta();
if (this.zzbsa.isEmpty() && !(this.zzbsa instanceof TreeMap)) {
TreeMap treeMap = new TreeMap();
this.zzbsa = treeMap;
this.zzbsc = treeMap.descendingMap();
}
return (SortedMap) this.zzbsa;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof zzwh)) {
return super.equals(obj);
}
zzwh zzwhVar = (zzwh) obj;
int size = size();
if (size != zzwhVar.size()) {
return false;
}
int zzsx = zzsx();
if (zzsx != zzwhVar.zzsx()) {
return entrySet().equals(zzwhVar.entrySet());
}
for (int i = 0; i < zzsx; i++) {
if (!zzdp(i).equals(zzwhVar.zzdp(i))) {
return false;
}
}
if (zzsx != size) {
return this.zzbsa.equals(zzwhVar.zzbsa);
}
return true;
}
@Override // java.util.AbstractMap, java.util.Map
public int hashCode() {
int zzsx = zzsx();
int i = 0;
for (int i2 = 0; i2 < zzsx; i2++) {
i += this.zzbrz.get(i2).hashCode();
}
return this.zzbsa.size() > 0 ? i + this.zzbsa.hashCode() : i;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
public /* synthetic */ Object put(Object obj, Object obj2) {
return zza((zzwh<K, V>) obj, (Comparable) obj2);
}
/* JADX INFO: Access modifiers changed from: package-private */
public /* synthetic */ zzwh(int i, zzwi zzwiVar) {
this(i);
}
public final boolean isImmutable() {
return this.zzbll;
}
}