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

108 lines
2.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import o.Vcx.Sts;
/* loaded from: classes.dex */
public class Vcx<T extends Sts> {
private static int a;
private T b;
float c;
private int d;
private Object[] e;
private int g;
private int j;
/* loaded from: classes.dex */
public static abstract class Sts {
int d = -1;
protected abstract Sts b();
}
public static Vcx d(int i, Sts sts) {
Vcx vcx;
synchronized (Vcx.class) {
vcx = new Vcx(i, sts);
int i2 = a;
vcx.g = i2;
a = i2 + 1;
}
return vcx;
}
private Vcx(int i, T t) {
if (i <= 0) {
throw new IllegalArgumentException("Object Pool must be instantiated with a capacity greater than 0!");
}
this.d = i;
this.e = new Object[i];
this.j = 0;
this.b = t;
this.c = 1.0f;
a(1.0f);
}
private void a(float f) {
int i = this.d;
int i2 = (int) (i * f);
if (i2 <= 0) {
i = 1;
} else if (i2 <= i) {
i = i2;
}
for (int i3 = 0; i3 < i; i3++) {
this.e[i3] = this.b.b();
}
this.j = i - 1;
}
public final void b(T t) {
synchronized (this) {
if (t.d != -1) {
if (t.d == this.g) {
throw new IllegalArgumentException("The object passed is already stored in this pool!");
}
StringBuilder sb = new StringBuilder("The object to recycle already belongs to poolId ");
sb.append(t.d);
sb.append(". Object cannot belong to two different pool instances simultaneously!");
throw new IllegalArgumentException(sb.toString());
}
int i = this.j + 1;
this.j = i;
if (i >= this.e.length) {
d();
}
t.d = this.g;
this.e[this.j] = t;
}
}
private void d() {
int i = this.d;
int i2 = i << 1;
this.d = i2;
Object[] objArr = new Object[i2];
for (int i3 = 0; i3 < i; i3++) {
objArr[i3] = this.e[i3];
}
this.e = objArr;
}
public final T a() {
T t;
synchronized (this) {
if (this.j == -1) {
float f = this.c;
if (f > BitmapDescriptorFactory.HUE_RED) {
a(f);
}
}
t = (T) this.e[this.j];
t.d = -1;
this.j--;
}
return t;
}
}