package L;

import P6.g;
import n4.u0;
import u.C1558c;

/* JADX INFO: loaded from: classes.dex */
public class b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f3621a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object[] f3622b;

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

    public b(int i) {
        this.f3621a = 0;
        if (i <= 0) {
            throw new IllegalArgumentException("The max pool size must be > 0");
        }
        this.f3622b = new Object[i];
    }

    public Object a() {
        switch (this.f3621a) {
            case u0.f15495q /* 0 */:
                int i = this.f3623c;
                if (i <= 0) {
                    return null;
                }
                int i5 = i - 1;
                Object[] objArr = this.f3622b;
                Object obj = objArr[i5];
                g.c(obj, "null cannot be cast to non-null type T of androidx.core.util.Pools.SimplePool");
                objArr[i5] = null;
                this.f3623c--;
                return obj;
            default:
                int i8 = this.f3623c;
                if (i8 <= 0) {
                    return null;
                }
                int i9 = i8 - 1;
                Object[] objArr2 = this.f3622b;
                Object obj2 = objArr2[i9];
                objArr2[i9] = null;
                this.f3623c = i8 - 1;
                return obj2;
        }
    }

    public void b(C1558c c1558c) {
        int i = this.f3623c;
        Object[] objArr = this.f3622b;
        if (i < objArr.length) {
            objArr[i] = c1558c;
            this.f3623c = i + 1;
        }
    }

    public boolean c(Object obj) {
        Object[] objArr;
        boolean z8;
        g.e(obj, "instance");
        int i = this.f3623c;
        int i5 = 0;
        while (true) {
            objArr = this.f3622b;
            if (i5 >= i) {
                z8 = false;
                break;
            }
            if (objArr[i5] == obj) {
                z8 = true;
                break;
            }
            i5++;
        }
        if (z8) {
            throw new IllegalStateException("Already in the pool!");
        }
        int i8 = this.f3623c;
        if (i8 >= objArr.length) {
            return false;
        }
        objArr[i8] = obj;
        this.f3623c = i8 + 1;
        return true;
    }

    public b() {
        this.f3621a = 1;
        this.f3622b = new Object[256];
    }
}
