what-the-bank/sources/com/google/android/gms/internal/vision/zzhz.java

274 lines
8.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.vision;
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 zzhz<K extends Comparable<K>, V> extends AbstractMap<K, V> {
private final int zzaae;
private List<zzig> zzaaf;
private Map<K, V> zzaag;
private volatile zzii zzaah;
private Map<K, V> zzaai;
private volatile zzic zzaaj;
private boolean zztn;
/* JADX INFO: Access modifiers changed from: package-private */
public static <FieldDescriptorType extends zzfr<FieldDescriptorType>> zzhz<FieldDescriptorType, Object> zzbo(int i) {
return new zzia(i);
}
private zzhz(int i) {
this.zzaae = i;
this.zzaaf = Collections.emptyList();
this.zzaag = Collections.emptyMap();
this.zzaai = Collections.emptyMap();
}
public void zzci() {
Map<K, V> unmodifiableMap;
Map<K, V> unmodifiableMap2;
if (this.zztn) {
return;
}
if (this.zzaag.isEmpty()) {
unmodifiableMap = Collections.emptyMap();
} else {
unmodifiableMap = Collections.unmodifiableMap(this.zzaag);
}
this.zzaag = unmodifiableMap;
if (this.zzaai.isEmpty()) {
unmodifiableMap2 = Collections.emptyMap();
} else {
unmodifiableMap2 = Collections.unmodifiableMap(this.zzaai);
}
this.zzaai = unmodifiableMap2;
this.zztn = true;
}
public final int zzgu() {
return this.zzaaf.size();
}
public final Map.Entry<K, V> zzbp(int i) {
return this.zzaaf.get(i);
}
public final Iterable<Map.Entry<K, V>> zzgv() {
if (this.zzaag.isEmpty()) {
return zzid.zzha();
}
return this.zzaag.entrySet();
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return this.zzaaf.size() + this.zzaag.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((zzhz<K, V>) comparable) >= 0 || this.zzaag.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((zzhz<K, V>) comparable);
if (zza >= 0) {
return (V) this.zzaaf.get(zza).getValue();
}
return this.zzaag.get(comparable);
}
/* JADX WARN: Multi-variable type inference failed */
public final V zza(K k, V v) {
zzgx();
int zza = zza((zzhz<K, V>) k);
if (zza >= 0) {
return (V) this.zzaaf.get(zza).setValue(v);
}
zzgx();
if (this.zzaaf.isEmpty() && !(this.zzaaf instanceof ArrayList)) {
this.zzaaf = new ArrayList(this.zzaae);
}
int i = -(zza + 1);
if (i >= this.zzaae) {
return zzgy().put(k, v);
}
int size = this.zzaaf.size();
int i2 = this.zzaae;
if (size == i2) {
zzig remove = this.zzaaf.remove(i2 - 1);
zzgy().put((Comparable) remove.getKey(), remove.getValue());
}
this.zzaaf.add(i, new zzig(this, k, v));
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
zzgx();
if (!this.zzaaf.isEmpty()) {
this.zzaaf.clear();
}
if (this.zzaag.isEmpty()) {
return;
}
this.zzaag.clear();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
zzgx();
Comparable comparable = (Comparable) obj;
int zza = zza((zzhz<K, V>) comparable);
if (zza >= 0) {
return (V) zzbq(zza);
}
if (this.zzaag.isEmpty()) {
return null;
}
return this.zzaag.remove(comparable);
}
/* JADX INFO: Access modifiers changed from: private */
public final V zzbq(int i) {
zzgx();
V v = (V) this.zzaaf.remove(i).getValue();
if (!this.zzaag.isEmpty()) {
Iterator<Map.Entry<K, V>> it = zzgy().entrySet().iterator();
this.zzaaf.add(new zzig(this, it.next()));
it.remove();
}
return v;
}
private final int zza(K k) {
int size = this.zzaaf.size();
int i = size - 1;
if (i >= 0) {
int compareTo = k.compareTo((Comparable) this.zzaaf.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.zzaaf.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.zzaah == null) {
this.zzaah = new zzii(this, null);
}
return this.zzaah;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final Set<Map.Entry<K, V>> zzgw() {
if (this.zzaaj == null) {
this.zzaaj = new zzic(this, null);
}
return this.zzaaj;
}
/* JADX INFO: Access modifiers changed from: private */
public final void zzgx() {
if (this.zztn) {
throw new UnsupportedOperationException();
}
}
private final SortedMap<K, V> zzgy() {
zzgx();
if (this.zzaag.isEmpty() && !(this.zzaag instanceof TreeMap)) {
TreeMap treeMap = new TreeMap();
this.zzaag = treeMap;
this.zzaai = treeMap.descendingMap();
}
return (SortedMap) this.zzaag;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof zzhz)) {
return super.equals(obj);
}
zzhz zzhzVar = (zzhz) obj;
int size = size();
if (size != zzhzVar.size()) {
return false;
}
int zzgu = zzgu();
if (zzgu != zzhzVar.zzgu()) {
return entrySet().equals(zzhzVar.entrySet());
}
for (int i = 0; i < zzgu; i++) {
if (!zzbp(i).equals(zzhzVar.zzbp(i))) {
return false;
}
}
if (zzgu != size) {
return this.zzaag.equals(zzhzVar.zzaag);
}
return true;
}
@Override // java.util.AbstractMap, java.util.Map
public int hashCode() {
int zzgu = zzgu();
int i = 0;
for (int i2 = 0; i2 < zzgu; i2++) {
i += this.zzaaf.get(i2).hashCode();
}
return this.zzaag.size() > 0 ? i + this.zzaag.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((zzhz<K, V>) obj, (Comparable) obj2);
}
/* JADX INFO: Access modifiers changed from: package-private */
public /* synthetic */ zzhz(int i, zzia zziaVar) {
this(i);
}
public final boolean isImmutable() {
return this.zztn;
}
}