what-the-bank/sources/com/pingan/ai/s.java

68 lines
1.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.pingan.ai;
/* loaded from: classes3.dex */
public class s<T> implements r<T> {
public final Object[] a;
public int b;
public s(int i) {
if (i > 0) {
this.a = new Object[i];
return;
}
throw new IllegalArgumentException("The max pool size must be > 0");
}
@Override // com.pingan.ai.r
public boolean a(T t) {
if (!b(t)) {
int i = this.b;
Object[] objArr = this.a;
if (i >= objArr.length) {
return false;
}
objArr[i] = t;
this.b = i + 1;
return true;
}
throw new IllegalStateException("Already in the pool!");
}
@Override // com.pingan.ai.r
public T b() {
int i = this.b;
if (i <= 0) {
return null;
}
int i2 = i - 1;
Object[] objArr = this.a;
T t = (T) objArr[i2];
objArr[i2] = null;
this.b = i2;
return t;
}
public final boolean b(T t) {
for (int i = 0; i < this.b; i++) {
if (this.a[i] == t) {
return true;
}
}
return false;
}
@Override // com.pingan.ai.r
public void a() {
int i = 0;
while (true) {
Object[] objArr = this.a;
if (i >= objArr.length) {
return;
}
objArr[i] = null;
this.b--;
i++;
}
}
}