238 lines
6.8 KiB
Java
238 lines
6.8 KiB
Java
package com.google.android.libraries.places.internal;
|
|
|
|
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 zzahe extends AbstractMap {
|
|
private final int zza;
|
|
private boolean zzd;
|
|
private volatile zzahc zze;
|
|
private List zzb = Collections.emptyList();
|
|
private Map zzc = Collections.emptyMap();
|
|
private Map zzf = Collections.emptyMap();
|
|
|
|
private final int zzk(Comparable comparable) {
|
|
int size = this.zzb.size();
|
|
int i = size - 1;
|
|
int i2 = 0;
|
|
if (i >= 0) {
|
|
int compareTo = comparable.compareTo(((zzagy) this.zzb.get(i)).zza());
|
|
if (compareTo > 0) {
|
|
return -(size + 1);
|
|
}
|
|
if (compareTo == 0) {
|
|
return i;
|
|
}
|
|
}
|
|
while (i2 <= i) {
|
|
int i3 = (i2 + i) / 2;
|
|
int compareTo2 = comparable.compareTo(((zzagy) this.zzb.get(i3)).zza());
|
|
if (compareTo2 < 0) {
|
|
i = i3 - 1;
|
|
} else {
|
|
if (compareTo2 <= 0) {
|
|
return i3;
|
|
}
|
|
i2 = i3 + 1;
|
|
}
|
|
}
|
|
return -(i2 + 1);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final Object zzl(int i) {
|
|
zzn();
|
|
Object value = ((zzagy) this.zzb.remove(i)).getValue();
|
|
if (!this.zzc.isEmpty()) {
|
|
Iterator it = zzm().entrySet().iterator();
|
|
List list = this.zzb;
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
list.add(new zzagy(this, (Comparable) entry.getKey(), entry.getValue()));
|
|
it.remove();
|
|
}
|
|
return value;
|
|
}
|
|
|
|
private final SortedMap zzm() {
|
|
zzn();
|
|
if (this.zzc.isEmpty() && !(this.zzc instanceof TreeMap)) {
|
|
TreeMap treeMap = new TreeMap();
|
|
this.zzc = treeMap;
|
|
this.zzf = treeMap.descendingMap();
|
|
}
|
|
return (SortedMap) this.zzc;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final void zzn() {
|
|
if (this.zzd) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final void clear() {
|
|
zzn();
|
|
if (!this.zzb.isEmpty()) {
|
|
this.zzb.clear();
|
|
}
|
|
if (this.zzc.isEmpty()) {
|
|
return;
|
|
}
|
|
this.zzc.clear();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final boolean containsKey(Object obj) {
|
|
Comparable comparable = (Comparable) obj;
|
|
return zzk(comparable) >= 0 || this.zzc.containsKey(comparable);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final Set entrySet() {
|
|
if (this.zze == null) {
|
|
this.zze = new zzahc(this, null);
|
|
}
|
|
return this.zze;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof zzahe)) {
|
|
return super.equals(obj);
|
|
}
|
|
zzahe zzaheVar = (zzahe) obj;
|
|
int size = size();
|
|
if (size != zzaheVar.size()) {
|
|
return false;
|
|
}
|
|
int zzb = zzb();
|
|
if (zzb != zzaheVar.zzb()) {
|
|
return entrySet().equals(zzaheVar.entrySet());
|
|
}
|
|
for (int i = 0; i < zzb; i++) {
|
|
if (!zzg(i).equals(zzaheVar.zzg(i))) {
|
|
return false;
|
|
}
|
|
}
|
|
if (zzb != size) {
|
|
return this.zzc.equals(zzaheVar.zzc);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final Object get(Object obj) {
|
|
Comparable comparable = (Comparable) obj;
|
|
int zzk = zzk(comparable);
|
|
if (zzk >= 0) {
|
|
return ((zzagy) this.zzb.get(zzk)).getValue();
|
|
}
|
|
return this.zzc.get(comparable);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final int hashCode() {
|
|
int zzb = zzb();
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < zzb; i2++) {
|
|
i += ((zzagy) this.zzb.get(i2)).hashCode();
|
|
}
|
|
return this.zzc.size() > 0 ? i + this.zzc.hashCode() : i;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final Object remove(Object obj) {
|
|
zzn();
|
|
Comparable comparable = (Comparable) obj;
|
|
int zzk = zzk(comparable);
|
|
if (zzk >= 0) {
|
|
return zzl(zzk);
|
|
}
|
|
if (this.zzc.isEmpty()) {
|
|
return null;
|
|
}
|
|
return this.zzc.remove(comparable);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public final int size() {
|
|
return this.zzb.size() + this.zzc.size();
|
|
}
|
|
|
|
public void zza() {
|
|
Map unmodifiableMap;
|
|
Map unmodifiableMap2;
|
|
if (this.zzd) {
|
|
return;
|
|
}
|
|
if (this.zzc.isEmpty()) {
|
|
unmodifiableMap = Collections.emptyMap();
|
|
} else {
|
|
unmodifiableMap = Collections.unmodifiableMap(this.zzc);
|
|
}
|
|
this.zzc = unmodifiableMap;
|
|
if (this.zzf.isEmpty()) {
|
|
unmodifiableMap2 = Collections.emptyMap();
|
|
} else {
|
|
unmodifiableMap2 = Collections.unmodifiableMap(this.zzf);
|
|
}
|
|
this.zzf = unmodifiableMap2;
|
|
this.zzd = true;
|
|
}
|
|
|
|
public final int zzb() {
|
|
return this.zzb.size();
|
|
}
|
|
|
|
public final Iterable zzc() {
|
|
return this.zzc.isEmpty() ? zzagx.zza() : this.zzc.entrySet();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
/* renamed from: zze, reason: merged with bridge method [inline-methods] */
|
|
public final Object put(Comparable comparable, Object obj) {
|
|
zzn();
|
|
int zzk = zzk(comparable);
|
|
if (zzk >= 0) {
|
|
return ((zzagy) this.zzb.get(zzk)).setValue(obj);
|
|
}
|
|
zzn();
|
|
if (this.zzb.isEmpty() && !(this.zzb instanceof ArrayList)) {
|
|
this.zzb = new ArrayList(this.zza);
|
|
}
|
|
int i = -(zzk + 1);
|
|
if (i >= this.zza) {
|
|
return zzm().put(comparable, obj);
|
|
}
|
|
int size = this.zzb.size();
|
|
int i2 = this.zza;
|
|
if (size == i2) {
|
|
zzagy zzagyVar = (zzagy) this.zzb.remove(i2 - 1);
|
|
zzm().put(zzagyVar.zza(), zzagyVar.getValue());
|
|
}
|
|
this.zzb.add(i, new zzagy(this, comparable, obj));
|
|
return null;
|
|
}
|
|
|
|
public final Map.Entry zzg(int i) {
|
|
return (Map.Entry) this.zzb.get(i);
|
|
}
|
|
|
|
public final boolean zzj() {
|
|
return this.zzd;
|
|
}
|
|
}
|