package androidx.collection;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int[] f936a;

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

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

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

    public h() {
        int iHighestOneBit = Integer.bitCount(8) != 1 ? Integer.highestOneBit(7) << 1 : 8;
        this.f939d = iHighestOneBit - 1;
        this.f936a = new int[iHighestOneBit];
    }

    public final void a(int i10) {
        int[] iArr = this.f936a;
        int i11 = this.f938c;
        iArr[i11] = i10;
        int i12 = this.f939d & (i11 + 1);
        this.f938c = i12;
        int i13 = this.f937b;
        if (i12 == i13) {
            int length = iArr.length;
            int i14 = length - i13;
            int i15 = length << 1;
            if (i15 < 0) {
                throw new RuntimeException("Max array capacity exceeded");
            }
            int[] iArr2 = new int[i15];
            kotlin.collections.q.P(0, i13, iArr, iArr2, length);
            kotlin.collections.q.P(i14, 0, this.f936a, iArr2, this.f937b);
            this.f936a = iArr2;
            this.f937b = 0;
            this.f938c = length;
            this.f939d = i15 - 1;
        }
    }

    public final int b() {
        int i10 = this.f937b;
        if (i10 == this.f938c) {
            throw new ArrayIndexOutOfBoundsException();
        }
        int i11 = this.f936a[i10];
        this.f937b = (i10 + 1) & this.f939d;
        return i11;
    }
}
