package d.h.i;

/* JADX INFO: loaded from: classes.dex */
public class d<T> {
    public final Object[] a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f2720b;

    public d(int i2) {
        if (i2 <= 0) {
            throw new IllegalArgumentException("The max pool size must be > 0");
        }
        this.a = new Object[i2];
    }

    public T a() {
        int i2 = this.f2720b;
        if (i2 <= 0) {
            return null;
        }
        int i3 = i2 - 1;
        Object[] objArr = this.a;
        T t2 = (T) objArr[i3];
        objArr[i3] = null;
        this.f2720b = i2 - 1;
        return t2;
    }

    public boolean b(T t2) {
        int i2;
        boolean z2;
        int i3 = 0;
        while (true) {
            i2 = this.f2720b;
            if (i3 >= i2) {
                z2 = false;
                break;
            }
            if (this.a[i3] == t2) {
                z2 = true;
                break;
            }
            i3++;
        }
        if (z2) {
            throw new IllegalStateException("Already in the pool!");
        }
        Object[] objArr = this.a;
        if (i2 >= objArr.length) {
            return false;
        }
        objArr[i2] = t2;
        this.f2720b = i2 + 1;
        return true;
    }
}
