what-the-bank/sources/com/facetec/sdk/ey.java

596 lines
17 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.facetec.sdk;
import com.huawei.hms.framework.common.ContainerUtils;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
/* loaded from: classes.dex */
public final class ey<K, V> extends AbstractMap<K, V> implements Serializable {
private static final Comparator<Comparable> e = new Comparator<Comparable>() { // from class: com.facetec.sdk.ey.3
@Override // java.util.Comparator
public final /* synthetic */ int compare(Comparable comparable, Comparable comparable2) {
return comparable.compareTo(comparable2);
}
};
private static boolean g = true;
final d<K, V> a;
int b;
private Comparator<? super K> c;
int d;
private d<K, V> h;
private ey<K, V>.e i;
private ey<K, V>.a j;
public ey() {
this(e);
}
private ey(Comparator<? super K> comparator) {
this.b = 0;
this.d = 0;
this.a = new d<>();
this.c = comparator == null ? e : comparator;
}
@Override // java.util.AbstractMap, java.util.Map
public final V get(Object obj) {
d<K, V> d2 = d(obj);
if (d2 != null) {
return d2.i;
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public final boolean containsKey(Object obj) {
return d(obj) != null;
}
@Override // java.util.AbstractMap, java.util.Map
public final V put(K k, V v) {
if (k == null) {
throw new NullPointerException("key == null");
}
d<K, V> e2 = e(k, true);
V v2 = e2.i;
e2.i = v;
return v2;
}
@Override // java.util.AbstractMap, java.util.Map
public final void clear() {
this.h = null;
this.b = 0;
this.d++;
d<K, V> dVar = this.a;
dVar.e = dVar;
dVar.b = dVar;
}
@Override // java.util.AbstractMap, java.util.Map
public final V remove(Object obj) {
d<K, V> a2 = a(obj);
if (a2 != null) {
return a2.i;
}
return null;
}
private d<K, V> e(K k, boolean z) {
int i;
d<K, V> dVar;
Comparator<? super K> comparator = this.c;
d<K, V> dVar2 = this.h;
if (dVar2 != null) {
Comparable comparable = comparator == e ? (Comparable) k : null;
while (true) {
if (comparable != null) {
i = comparable.compareTo(dVar2.j);
} else {
i = comparator.compare(k, dVar2.j);
}
if (i != 0) {
d<K, V> dVar3 = i < 0 ? dVar2.d : dVar2.c;
if (dVar3 == null) {
break;
}
dVar2 = dVar3;
} else {
return dVar2;
}
}
} else {
i = 0;
}
if (!z) {
return null;
}
d<K, V> dVar4 = this.a;
if (dVar2 == null) {
if (comparator == e && !(k instanceof Comparable)) {
StringBuilder sb = new StringBuilder();
sb.append(k.getClass().getName());
sb.append(" is not Comparable");
throw new ClassCastException(sb.toString());
}
dVar = new d<>(dVar2, k, dVar4, dVar4.e);
this.h = dVar;
} else {
dVar = new d<>(dVar2, k, dVar4, dVar4.e);
if (i < 0) {
dVar2.d = dVar;
} else {
dVar2.c = dVar;
}
c(dVar2, true);
}
this.b++;
this.d++;
return dVar;
}
/* JADX WARN: Multi-variable type inference failed */
private d<K, V> d(Object obj) {
if (obj == 0) {
return null;
}
try {
return e(obj, false);
} catch (ClassCastException unused) {
return null;
}
}
final d<K, V> d(Map.Entry<?, ?> entry) {
d<K, V> d2 = d(entry.getKey());
if (d2 == null || !b(d2.i, entry.getValue())) {
return null;
}
return d2;
}
private static boolean b(Object obj, Object obj2) {
if (obj != obj2) {
return obj != null && obj.equals(obj2);
}
return true;
}
final void a(d<K, V> dVar, boolean z) {
int i;
if (z) {
dVar.e.b = dVar.b;
dVar.b.e = dVar.e;
}
d<K, V> dVar2 = dVar.d;
d<K, V> dVar3 = dVar.c;
d<K, V> dVar4 = dVar.a;
int i2 = 0;
if (dVar2 != null && dVar3 != null) {
if (dVar2.h > dVar3.h) {
d<K, V> dVar5 = dVar2.c;
while (dVar5 != null) {
d<K, V> dVar6 = dVar5;
dVar5 = dVar5.c;
dVar2 = dVar6;
}
} else {
while (true) {
d<K, V> dVar7 = dVar3.d;
if (dVar7 == null) {
break;
} else {
dVar3 = dVar7;
}
}
dVar2 = dVar3;
}
a((d) dVar2, false);
d<K, V> dVar8 = dVar.d;
if (dVar8 != null) {
i = dVar8.h;
dVar2.d = dVar8;
dVar8.a = dVar2;
dVar.d = null;
} else {
i = 0;
}
d<K, V> dVar9 = dVar.c;
if (dVar9 != null) {
i2 = dVar9.h;
dVar2.c = dVar9;
dVar9.a = dVar2;
dVar.c = null;
}
dVar2.h = Math.max(i, i2) + 1;
a(dVar, dVar2);
return;
}
if (dVar2 != null) {
a(dVar, dVar2);
dVar.d = null;
} else if (dVar3 != null) {
a(dVar, dVar3);
dVar.c = null;
} else {
a(dVar, (d) null);
}
c(dVar4, false);
this.b--;
this.d++;
}
final d<K, V> a(Object obj) {
d<K, V> d2 = d(obj);
if (d2 != null) {
a((d) d2, true);
}
return d2;
}
private void a(d<K, V> dVar, d<K, V> dVar2) {
d<K, V> dVar3 = dVar.a;
dVar.a = null;
if (dVar2 != null) {
dVar2.a = dVar3;
}
if (dVar3 == null) {
this.h = dVar2;
return;
}
if (dVar3.d == dVar) {
dVar3.d = dVar2;
} else {
if (!g && dVar3.c != dVar) {
throw new AssertionError();
}
dVar3.c = dVar2;
}
}
private void c(d<K, V> dVar, boolean z) {
while (dVar != null) {
d<K, V> dVar2 = dVar.d;
d<K, V> dVar3 = dVar.c;
int i = dVar2 != null ? dVar2.h : 0;
int i2 = dVar3 != null ? dVar3.h : 0;
int i3 = i - i2;
if (i3 == -2) {
d<K, V> dVar4 = dVar3.d;
d<K, V> dVar5 = dVar3.c;
int i4 = (dVar4 != null ? dVar4.h : 0) - (dVar5 != null ? dVar5.h : 0);
if (i4 != -1 && (i4 != 0 || z)) {
if (!g && i4 != 1) {
throw new AssertionError();
}
e(dVar3);
}
b(dVar);
if (z) {
return;
}
} else if (i3 == 2) {
d<K, V> dVar6 = dVar2.d;
d<K, V> dVar7 = dVar2.c;
int i5 = (dVar6 != null ? dVar6.h : 0) - (dVar7 != null ? dVar7.h : 0);
if (i5 != 1 && (i5 != 0 || z)) {
if (!g && i5 != -1) {
throw new AssertionError();
}
b(dVar2);
}
e(dVar);
if (z) {
return;
}
} else if (i3 == 0) {
dVar.h = i + 1;
if (z) {
return;
}
} else {
if (!g && i3 != -1 && i3 != 1) {
throw new AssertionError();
}
dVar.h = Math.max(i, i2) + 1;
if (!z) {
return;
}
}
dVar = dVar.a;
}
}
private void b(d<K, V> dVar) {
d<K, V> dVar2 = dVar.d;
d<K, V> dVar3 = dVar.c;
d<K, V> dVar4 = dVar3.d;
d<K, V> dVar5 = dVar3.c;
dVar.c = dVar4;
if (dVar4 != null) {
dVar4.a = dVar;
}
a(dVar, dVar3);
dVar3.d = dVar;
dVar.a = dVar3;
dVar.h = Math.max(dVar2 != null ? dVar2.h : 0, dVar4 != null ? dVar4.h : 0) + 1;
dVar3.h = Math.max(dVar.h, dVar5 != null ? dVar5.h : 0) + 1;
}
private void e(d<K, V> dVar) {
d<K, V> dVar2 = dVar.d;
d<K, V> dVar3 = dVar.c;
d<K, V> dVar4 = dVar2.d;
d<K, V> dVar5 = dVar2.c;
dVar.d = dVar5;
if (dVar5 != null) {
dVar5.a = dVar;
}
a(dVar, dVar2);
dVar2.c = dVar;
dVar.a = dVar2;
dVar.h = Math.max(dVar3 != null ? dVar3.h : 0, dVar5 != null ? dVar5.h : 0) + 1;
dVar2.h = Math.max(dVar.h, dVar4 != null ? dVar4.h : 0) + 1;
}
@Override // java.util.AbstractMap, java.util.Map
public final Set<Map.Entry<K, V>> entrySet() {
ey<K, V>.a aVar = this.j;
if (aVar != null) {
return aVar;
}
ey<K, V>.a aVar2 = new a(this);
this.j = aVar2;
return aVar2;
}
@Override // java.util.AbstractMap, java.util.Map
public final Set<K> keySet() {
ey<K, V>.e eVar = this.i;
if (eVar != null) {
return eVar;
}
ey<K, V>.e eVar2 = new e(this);
this.i = eVar2;
return eVar2;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static final class d<K, V> implements Map.Entry<K, V> {
d<K, V> a;
d<K, V> b;
d<K, V> c;
d<K, V> d;
d<K, V> e;
int h;
V i;
final K j;
d() {
this.j = null;
this.e = this;
this.b = this;
}
d(d<K, V> dVar, K k, d<K, V> dVar2, d<K, V> dVar3) {
this.a = dVar;
this.j = k;
this.h = 1;
this.b = dVar2;
this.e = dVar3;
dVar3.b = this;
dVar2.e = this;
}
@Override // java.util.Map.Entry
public final boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
K k = this.j;
if (k == null) {
if (entry.getKey() != null) {
return false;
}
} else if (!k.equals(entry.getKey())) {
return false;
}
V v = this.i;
return v == null ? entry.getValue() == null : v.equals(entry.getValue());
}
@Override // java.util.Map.Entry
public final int hashCode() {
K k = this.j;
int hashCode = k == null ? 0 : k.hashCode();
V v = this.i;
return hashCode ^ (v != null ? v.hashCode() : 0);
}
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.j);
sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
sb.append(this.i);
return sb.toString();
}
@Override // java.util.Map.Entry
public final V setValue(V v) {
V v2 = this.i;
this.i = v;
return v2;
}
@Override // java.util.Map.Entry
public final V getValue() {
return this.i;
}
@Override // java.util.Map.Entry
public final K getKey() {
return this.j;
}
}
/* loaded from: classes.dex */
abstract class b<T> implements Iterator<T> {
private ey a;
private d<K, V> b = null;
private d<K, V> c;
private int d;
b(ey eyVar) {
this.a = eyVar;
this.c = this.a.a.b;
this.d = this.a.d;
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.c != this.a.a;
}
final d<K, V> a() {
d<K, V> dVar = this.c;
if (dVar == this.a.a) {
throw new NoSuchElementException();
}
if (this.a.d != this.d) {
throw new ConcurrentModificationException();
}
this.c = dVar.b;
this.b = dVar;
return dVar;
}
@Override // java.util.Iterator
public final void remove() {
d<K, V> dVar = this.b;
if (dVar == null) {
throw new IllegalStateException();
}
this.a.a((d) dVar, true);
this.b = null;
this.d = this.a.d;
}
}
/* loaded from: classes.dex */
final class a extends AbstractSet<Map.Entry<K, V>> {
final ey c;
a(ey eyVar) {
this.c = eyVar;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.c.b;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<Map.Entry<K, V>> iterator() {
return new b(this) { // from class: com.facetec.sdk.ey.a.1
private a c;
{
this.c = this;
ey eyVar = this.c;
}
@Override // java.util.Iterator
public final /* synthetic */ Object next() {
return a();
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return (obj instanceof Map.Entry) && this.c.d((Map.Entry<?, ?>) obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
d<K, V> d;
if (!(obj instanceof Map.Entry) || (d = this.c.d((Map.Entry<?, ?>) obj)) == null) {
return false;
}
this.c.a((d) d, true);
return true;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final void clear() {
this.c.clear();
}
}
/* loaded from: classes.dex */
final class e extends AbstractSet<K> {
final ey b;
e(ey eyVar) {
this.b = eyVar;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.b.b;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<K> iterator() {
return new b(this) { // from class: com.facetec.sdk.ey.e.5
private e b;
{
this.b = this;
ey eyVar = this.b;
}
@Override // java.util.Iterator
public final K next() {
return a().j;
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return this.b.containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
return this.b.a(obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final void clear() {
this.b.clear();
}
}
private Object writeReplace() throws ObjectStreamException {
return new LinkedHashMap(this);
}
@Override // java.util.AbstractMap, java.util.Map
public final int size() {
return this.b;
}
}