what-the-bank/sources/o/wnv.java

478 lines
13 KiB
Java

package o;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import o.qXr;
/* loaded from: classes.dex */
public final class wnv<E> implements Collection<E>, Set<E> {
private static Object[] e;
private static int f;
private static int h;
private static Object[] j;
public Object[] a;
int c;
private int[] g;
private qXr<E, E> i;
private static final int[] d = new int[0];
private static final Object[] b = new Object[0];
final int e(Object obj, int i) {
int i2 = this.c;
if (i2 == 0) {
return -1;
}
int e2 = C6569cWs.e(this.g, i2, i);
if (e2 < 0 || obj.equals(this.a[e2])) {
return e2;
}
int i3 = e2 + 1;
while (i3 < i2 && this.g[i3] == i) {
if (obj.equals(this.a[i3])) {
return i3;
}
i3++;
}
for (int i4 = e2 - 1; i4 >= 0 && this.g[i4] == i; i4--) {
if (obj.equals(this.a[i4])) {
return i4;
}
}
return ~i3;
}
final int a() {
int i = this.c;
if (i == 0) {
return -1;
}
int e2 = C6569cWs.e(this.g, i, 0);
if (e2 < 0 || this.a[e2] == null) {
return e2;
}
int i2 = e2 + 1;
while (i2 < i && this.g[i2] == 0) {
if (this.a[i2] == null) {
return i2;
}
i2++;
}
for (int i3 = e2 - 1; i3 >= 0 && this.g[i3] == 0; i3--) {
if (this.a[i3] == null) {
return i3;
}
}
return ~i2;
}
private void b(int i) {
if (i == 8) {
synchronized (wnv.class) {
Object[] objArr = j;
if (objArr != null) {
this.a = objArr;
j = (Object[]) objArr[0];
this.g = (int[]) objArr[1];
objArr[1] = null;
objArr[0] = null;
f--;
return;
}
}
} else if (i == 4) {
synchronized (wnv.class) {
Object[] objArr2 = e;
if (objArr2 != null) {
this.a = objArr2;
e = (Object[]) objArr2[0];
this.g = (int[]) objArr2[1];
objArr2[1] = null;
objArr2[0] = null;
h--;
return;
}
}
}
this.g = new int[i];
this.a = new Object[i];
}
private static void e(int[] iArr, Object[] objArr, int i) {
if (iArr.length == 8) {
synchronized (wnv.class) {
if (f < 10) {
objArr[0] = j;
objArr[1] = iArr;
while (true) {
i--;
if (i < 2) {
break;
} else {
objArr[i] = null;
}
}
j = objArr;
f++;
}
}
return;
}
if (iArr.length == 4) {
synchronized (wnv.class) {
if (h < 10) {
objArr[0] = e;
objArr[1] = iArr;
while (true) {
i--;
if (i < 2) {
break;
} else {
objArr[i] = null;
}
}
e = objArr;
h++;
}
}
}
}
public wnv() {
this(0);
}
public wnv(int i) {
if (i == 0) {
this.g = d;
this.a = b;
} else {
b(i);
}
this.c = 0;
}
@Override // java.util.Collection, java.util.Set
public final void clear() {
int i = this.c;
if (i != 0) {
e(this.g, this.a, i);
this.g = d;
this.a = b;
this.c = 0;
}
}
@Override // java.util.Collection, java.util.Set
public final boolean add(E e2) {
int i;
int e3;
if (e2 == null) {
e3 = a();
i = 0;
} else {
int hashCode = e2.hashCode();
i = hashCode;
e3 = e(e2, hashCode);
}
if (e3 >= 0) {
return false;
}
int i2 = ~e3;
int i3 = this.c;
int[] iArr = this.g;
if (i3 >= iArr.length) {
int i4 = 8;
if (i3 >= 8) {
i4 = (i3 >> 1) + i3;
} else if (i3 < 4) {
i4 = 4;
}
Object[] objArr = this.a;
b(i4);
int[] iArr2 = this.g;
if (iArr2.length > 0) {
System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
System.arraycopy(objArr, 0, this.a, 0, objArr.length);
}
e(iArr, objArr, this.c);
}
int i5 = this.c;
if (i2 < i5) {
int[] iArr3 = this.g;
int i6 = i2 + 1;
System.arraycopy(iArr3, i2, iArr3, i6, i5 - i2);
Object[] objArr2 = this.a;
System.arraycopy(objArr2, i2, objArr2, i6, this.c - i2);
}
this.g[i2] = i;
this.a[i2] = e2;
this.c++;
return true;
}
public final E a(int i) {
Object[] objArr = this.a;
E e2 = (E) objArr[i];
int i2 = this.c;
if (i2 <= 1) {
e(this.g, objArr, i2);
this.g = d;
this.a = b;
this.c = 0;
} else {
int[] iArr = this.g;
if (iArr.length > 8 && i2 < iArr.length / 3) {
b(i2 > 8 ? i2 + (i2 >> 1) : 8);
this.c--;
if (i > 0) {
System.arraycopy(iArr, 0, this.g, 0, i);
System.arraycopy(objArr, 0, this.a, 0, i);
}
int i3 = this.c;
if (i < i3) {
int i4 = i + 1;
System.arraycopy(iArr, i4, this.g, i, i3 - i);
System.arraycopy(objArr, i4, this.a, i, this.c - i);
}
} else {
int i5 = i2 - 1;
this.c = i5;
if (i < i5) {
int i6 = i + 1;
System.arraycopy(iArr, i6, iArr, i, i5 - i);
Object[] objArr2 = this.a;
System.arraycopy(objArr2, i6, objArr2, i, this.c - i);
}
this.a[this.c] = null;
}
}
return e2;
}
@Override // java.util.Collection, java.util.Set
public final Object[] toArray() {
int i = this.c;
Object[] objArr = new Object[i];
System.arraycopy(this.a, 0, objArr, 0, i);
return objArr;
}
@Override // java.util.Collection, java.util.Set
public final <T> T[] toArray(T[] tArr) {
if (tArr.length < this.c) {
tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), this.c));
}
System.arraycopy(this.a, 0, tArr, 0, this.c);
int length = tArr.length;
int i = this.c;
if (length > i) {
tArr[i] = null;
}
return tArr;
}
@Override // java.util.Collection, java.util.Set
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Set) {
Set set = (Set) obj;
if (size() != set.size()) {
return false;
}
for (int i = 0; i < this.c; i++) {
try {
if (!set.contains(this.a[i])) {
return false;
}
} catch (ClassCastException | NullPointerException unused) {
}
}
return true;
}
return false;
}
@Override // java.util.Collection, java.util.Set
public final int hashCode() {
int[] iArr = this.g;
int i = this.c;
int i2 = 0;
for (int i3 = 0; i3 < i; i3++) {
i2 += iArr[i3];
}
return i2;
}
public final String toString() {
if (isEmpty()) {
return "{}";
}
StringBuilder sb = new StringBuilder(this.c * 14);
sb.append(UrlTreeKt.componentParamPrefixChar);
for (int i = 0; i < this.c; i++) {
if (i > 0) {
sb.append(", ");
}
Object obj = this.a[i];
if (obj != this) {
sb.append(obj);
} else {
sb.append("(this Set)");
}
}
sb.append(UrlTreeKt.componentParamSuffixChar);
return sb.toString();
}
@Override // java.util.Collection, java.lang.Iterable, java.util.Set
public final Iterator<E> iterator() {
if (this.i == null) {
this.i = new qXr<E, E>(this) { // from class: o.wnv.3
final wnv d;
{
this.d = this;
}
@Override // o.qXr
protected final int e() {
return this.d.c;
}
@Override // o.qXr
protected final Object e(int i, int i2) {
return this.d.a[i];
}
@Override // o.qXr
protected final Map<E, E> b() {
throw new UnsupportedOperationException("not a map");
}
@Override // o.qXr
protected final void b(E e2, E e3) {
this.d.add(e2);
}
@Override // o.qXr
protected final E c(int i, E e2) {
throw new UnsupportedOperationException("not a map");
}
@Override // o.qXr
protected final void a(int i) {
this.d.a(i);
}
@Override // o.qXr
protected final void a() {
this.d.clear();
}
@Override // o.qXr
protected final int b(Object obj) {
wnv wnvVar = this.d;
return obj == null ? wnvVar.a() : wnvVar.e(obj, obj.hashCode());
}
@Override // o.qXr
protected final int a(Object obj) {
wnv wnvVar = this.d;
return obj == null ? wnvVar.a() : wnvVar.e(obj, obj.hashCode());
}
};
}
qXr<E, E> qxr = this.i;
if (qxr.a == null) {
qxr.a = new qXr.LWm(qxr);
}
return qxr.a.iterator();
}
@Override // java.util.Collection, java.util.Set
public final boolean containsAll(Collection<?> collection) {
Iterator<?> it = collection.iterator();
while (it.hasNext()) {
if (!contains(it.next())) {
return false;
}
}
return true;
}
@Override // java.util.Collection, java.util.Set
public final boolean addAll(Collection<? extends E> collection) {
int size = this.c + collection.size();
int[] iArr = this.g;
boolean z = false;
if (iArr.length < size) {
Object[] objArr = this.a;
b(size);
int i = this.c;
if (i > 0) {
System.arraycopy(iArr, 0, this.g, 0, i);
System.arraycopy(objArr, 0, this.a, 0, this.c);
}
e(iArr, objArr, this.c);
}
Iterator<? extends E> it = collection.iterator();
while (it.hasNext()) {
z |= add(it.next());
}
return z;
}
@Override // java.util.Collection, java.util.Set
public final boolean removeAll(Collection<?> collection) {
Iterator<?> it = collection.iterator();
boolean z = false;
while (it.hasNext()) {
z |= remove(it.next());
}
return z;
}
@Override // java.util.Collection, java.util.Set
public final boolean retainAll(Collection<?> collection) {
boolean z = false;
for (int i = this.c - 1; i >= 0; i--) {
if (!collection.contains(this.a[i])) {
a(i);
z = true;
}
}
return z;
}
@Override // java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return (obj == null ? a() : e(obj, obj.hashCode())) >= 0;
}
@Override // java.util.Collection, java.util.Set
public final boolean remove(Object obj) {
int a = obj == null ? a() : e(obj, obj.hashCode());
if (a < 0) {
return false;
}
a(a);
return true;
}
@Override // java.util.Collection, java.util.Set
public final int size() {
return this.c;
}
@Override // java.util.Collection, java.util.Set
public final boolean isEmpty() {
return this.c <= 0;
}
}