package E1;

import kotlin.jvm.internal.o;
import n1.C2608b;

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

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

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

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

    public Object a() {
        int i6 = this.f1118b;
        if (i6 <= 0) {
            return null;
        }
        int i7 = i6 - 1;
        Object[] objArr = this.f1117a;
        Object obj = objArr[i7];
        o.f(obj, "null cannot be cast to non-null type T of androidx.core.util.Pools.SimplePool");
        objArr[i7] = null;
        this.f1118b--;
        return obj;
    }

    public void b(Object instance) {
        o.h(instance, "instance");
        int i6 = this.f1118b;
        int i7 = 0;
        while (true) {
            Object[] objArr = this.f1117a;
            if (i7 >= i6) {
                int i8 = this.f1118b;
                if (i8 < objArr.length) {
                    objArr[i8] = instance;
                    this.f1118b = i8 + 1;
                    return;
                }
                return;
            }
            if (objArr[i7] == instance) {
                throw new IllegalStateException("Already in the pool!");
            }
            i7++;
        }
    }

    public void c(C2608b c2608b) {
        int i6 = this.f1118b;
        Object[] objArr = this.f1117a;
        if (i6 < objArr.length) {
            objArr[i6] = c2608b;
            this.f1118b = i6 + 1;
        }
    }

    public c() {
        this.f1117a = new Object[256];
    }
}
