jimu-decompiled/sources/androidx/core/util/Pools$SimplePool.java
2025-05-13 19:24:51 +02:00

53 lines
1.2 KiB
Java

package androidx.core.util;
/* loaded from: classes.dex */
public class Pools$SimplePool<T> implements Pools$Pool<T> {
private final Object[] a;
private int b;
public Pools$SimplePool(int i) {
if (i <= 0) {
throw new IllegalArgumentException("The max pool size must be > 0");
}
this.a = new Object[i];
}
private boolean b(T t) {
for (int i = 0; i < this.b; i++) {
if (this.a[i] == t) {
return true;
}
}
return false;
}
@Override // androidx.core.util.Pools$Pool
public T a() {
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 = i - 1;
return t;
}
@Override // androidx.core.util.Pools$Pool
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!");
}
}