250 lines
6.8 KiB
Java
250 lines
6.8 KiB
Java
package com.google.android.gms.internal.measurement;
|
|
|
|
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;
|
|
|
|
/* loaded from: classes.dex */
|
|
class zzwo<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
|
private final int a;
|
|
private List<zzwv> b;
|
|
private Map<K, V> c;
|
|
private boolean d;
|
|
private volatile zzwx e;
|
|
private Map<K, V> f;
|
|
private volatile zzwr g;
|
|
|
|
private zzwo(int i) {
|
|
this.a = i;
|
|
this.b = Collections.emptyList();
|
|
this.c = Collections.emptyMap();
|
|
this.f = Collections.emptyMap();
|
|
}
|
|
|
|
static <FieldDescriptorType extends zzuh<FieldDescriptorType>> zzwo<FieldDescriptorType, Object> b(int i) {
|
|
return new zzwp(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final void f() {
|
|
if (this.d) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
private final SortedMap<K, V> g() {
|
|
f();
|
|
if (this.c.isEmpty() && !(this.c instanceof TreeMap)) {
|
|
this.c = new TreeMap();
|
|
this.f = ((TreeMap) this.c).descendingMap();
|
|
}
|
|
return (SortedMap) this.c;
|
|
}
|
|
|
|
public final boolean a() {
|
|
return this.d;
|
|
}
|
|
|
|
public final int c() {
|
|
return this.b.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
f();
|
|
if (!this.b.isEmpty()) {
|
|
this.b.clear();
|
|
}
|
|
if (this.c.isEmpty()) {
|
|
return;
|
|
}
|
|
this.c.clear();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
Comparable comparable = (Comparable) obj;
|
|
return a((zzwo<K, V>) comparable) >= 0 || this.c.containsKey(comparable);
|
|
}
|
|
|
|
public final Iterable<Map.Entry<K, V>> d() {
|
|
return this.c.isEmpty() ? zzws.a() : this.c.entrySet();
|
|
}
|
|
|
|
final Set<Map.Entry<K, V>> e() {
|
|
if (this.g == null) {
|
|
this.g = new zzwr(this, null);
|
|
}
|
|
return this.g;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Set<Map.Entry<K, V>> entrySet() {
|
|
if (this.e == null) {
|
|
this.e = new zzwx(this, null);
|
|
}
|
|
return this.e;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof zzwo)) {
|
|
return super.equals(obj);
|
|
}
|
|
zzwo zzwoVar = (zzwo) obj;
|
|
int size = size();
|
|
if (size != zzwoVar.size()) {
|
|
return false;
|
|
}
|
|
int c = c();
|
|
if (c != zzwoVar.c()) {
|
|
return entrySet().equals(zzwoVar.entrySet());
|
|
}
|
|
for (int i = 0; i < c; i++) {
|
|
if (!a(i).equals(zzwoVar.a(i))) {
|
|
return false;
|
|
}
|
|
}
|
|
if (c != size) {
|
|
return this.c.equals(zzwoVar.c);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V get(Object obj) {
|
|
Comparable comparable = (Comparable) obj;
|
|
int a = a((zzwo<K, V>) comparable);
|
|
return a >= 0 ? (V) this.b.get(a).getValue() : this.c.get(comparable);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int hashCode() {
|
|
int c = c();
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < c; i2++) {
|
|
i += this.b.get(i2).hashCode();
|
|
}
|
|
return this.c.size() > 0 ? i + this.c.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 a((zzwo<K, V>) obj, (Comparable) obj2);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V remove(Object obj) {
|
|
f();
|
|
Comparable comparable = (Comparable) obj;
|
|
int a = a((zzwo<K, V>) comparable);
|
|
if (a >= 0) {
|
|
return (V) c(a);
|
|
}
|
|
if (this.c.isEmpty()) {
|
|
return null;
|
|
}
|
|
return this.c.remove(comparable);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
return this.b.size() + this.c.size();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final V c(int i) {
|
|
f();
|
|
V v = (V) this.b.remove(i).getValue();
|
|
if (!this.c.isEmpty()) {
|
|
Iterator<Map.Entry<K, V>> it = g().entrySet().iterator();
|
|
this.b.add(new zzwv(this, it.next()));
|
|
it.remove();
|
|
}
|
|
return v;
|
|
}
|
|
|
|
public final Map.Entry<K, V> a(int i) {
|
|
return this.b.get(i);
|
|
}
|
|
|
|
public void b() {
|
|
if (this.d) {
|
|
return;
|
|
}
|
|
this.c = this.c.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(this.c);
|
|
this.f = this.f.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(this.f);
|
|
this.d = true;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final V a(K k, V v) {
|
|
f();
|
|
int a = a((zzwo<K, V>) k);
|
|
if (a >= 0) {
|
|
return (V) this.b.get(a).setValue(v);
|
|
}
|
|
f();
|
|
if (this.b.isEmpty() && !(this.b instanceof ArrayList)) {
|
|
this.b = new ArrayList(this.a);
|
|
}
|
|
int i = -(a + 1);
|
|
if (i >= this.a) {
|
|
return g().put(k, v);
|
|
}
|
|
int size = this.b.size();
|
|
int i2 = this.a;
|
|
if (size == i2) {
|
|
zzwv remove = this.b.remove(i2 - 1);
|
|
g().put((Comparable) remove.getKey(), remove.getValue());
|
|
}
|
|
this.b.add(i, new zzwv(this, k, v));
|
|
return null;
|
|
}
|
|
|
|
/* synthetic */ zzwo(int i, zzwp zzwpVar) {
|
|
this(i);
|
|
}
|
|
|
|
private final int a(K k) {
|
|
int size = this.b.size() - 1;
|
|
if (size >= 0) {
|
|
int compareTo = k.compareTo((Comparable) this.b.get(size).getKey());
|
|
if (compareTo > 0) {
|
|
return -(size + 2);
|
|
}
|
|
if (compareTo == 0) {
|
|
return size;
|
|
}
|
|
}
|
|
int i = 0;
|
|
while (i <= size) {
|
|
int i2 = (i + size) / 2;
|
|
int compareTo2 = k.compareTo((Comparable) this.b.get(i2).getKey());
|
|
if (compareTo2 < 0) {
|
|
size = i2 - 1;
|
|
} else {
|
|
if (compareTo2 <= 0) {
|
|
return i2;
|
|
}
|
|
i = i2 + 1;
|
|
}
|
|
}
|
|
return -(i + 1);
|
|
}
|
|
}
|