package tb;

import java.util.Arrays;

/* JADX INFO: loaded from: classes.dex */
public final class a implements Cloneable {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final int[] f33002c = new int[0];

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

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

    public a() {
        this.f33004b = 0;
        this.f33003a = f33002c;
    }

    public final void a(boolean z10) {
        c(this.f33004b + 1);
        if (z10) {
            int[] iArr = this.f33003a;
            int i10 = this.f33004b;
            int i11 = i10 / 32;
            iArr[i11] = (1 << (i10 & 31)) | iArr[i11];
        }
        this.f33004b++;
    }

    public final void b(int i10, int i11) {
        if (i11 < 0 || i11 > 32) {
            throw new IllegalArgumentException("Num bits must be between 0 and 32");
        }
        int i12 = this.f33004b;
        c(i12 + i11);
        for (int i13 = i11 - 1; i13 >= 0; i13--) {
            if (((1 << i13) & i10) != 0) {
                int[] iArr = this.f33003a;
                int i14 = i12 / 32;
                iArr[i14] = iArr[i14] | (1 << (i12 & 31));
            }
            i12++;
        }
        this.f33004b = i12;
    }

    public final void c(int i10) {
        if (i10 > this.f33003a.length * 32) {
            int[] iArr = new int[(((int) Math.ceil(i10 / 0.75f)) + 31) / 32];
            int[] iArr2 = this.f33003a;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            this.f33003a = iArr;
        }
    }

    public final Object clone() {
        int[] iArr = (int[]) this.f33003a.clone();
        int i10 = this.f33004b;
        a aVar = new a();
        aVar.f33003a = iArr;
        aVar.f33004b = i10;
        return aVar;
    }

    public final boolean d(int i10) {
        return ((1 << (i10 & 31)) & this.f33003a[i10 / 32]) != 0;
    }

    public final int e(int i10) {
        int i11 = this.f33004b;
        if (i10 >= i11) {
            return i11;
        }
        int i12 = i10 / 32;
        int i13 = (-(1 << (i10 & 31))) & this.f33003a[i12];
        while (i13 == 0) {
            i12++;
            int[] iArr = this.f33003a;
            if (i12 == iArr.length) {
                return this.f33004b;
            }
            i13 = iArr[i12];
        }
        return Math.min(Integer.numberOfTrailingZeros(i13) + (i12 * 32), this.f33004b);
    }

    public final boolean equals(Object obj) {
        if (!(obj instanceof a)) {
            return false;
        }
        a aVar = (a) obj;
        return this.f33004b == aVar.f33004b && Arrays.equals(this.f33003a, aVar.f33003a);
    }

    public final int f(int i10) {
        int i11 = this.f33004b;
        if (i10 >= i11) {
            return i11;
        }
        int i12 = i10 / 32;
        int i13 = (-(1 << (i10 & 31))) & (~this.f33003a[i12]);
        while (i13 == 0) {
            i12++;
            int[] iArr = this.f33003a;
            if (i12 == iArr.length) {
                return this.f33004b;
            }
            i13 = ~iArr[i12];
        }
        return Math.min(Integer.numberOfTrailingZeros(i13) + (i12 * 32), this.f33004b);
    }

    public final int g() {
        return (this.f33004b + 7) / 8;
    }

    public final boolean h(int i10, int i11) {
        if (i11 < i10 || i10 < 0 || i11 > this.f33004b) {
            throw new IllegalArgumentException();
        }
        if (i11 == i10) {
            return true;
        }
        int i12 = i11 - 1;
        int i13 = i10 / 32;
        int i14 = i12 / 32;
        int i15 = i13;
        while (i15 <= i14) {
            if ((((2 << (i15 >= i14 ? 31 & i12 : 31)) - (1 << (i15 > i13 ? 0 : i10 & 31))) & this.f33003a[i15]) != 0) {
                return false;
            }
            i15++;
        }
        return true;
    }

    public final int hashCode() {
        return Arrays.hashCode(this.f33003a) + (this.f33004b * 31);
    }

    public final void i() {
        int[] iArr = new int[this.f33003a.length];
        int i10 = (this.f33004b - 1) / 32;
        int i11 = i10 + 1;
        for (int i12 = 0; i12 < i11; i12++) {
            iArr[i10 - i12] = Integer.reverse(this.f33003a[i12]);
        }
        int i13 = this.f33004b;
        int i14 = i11 * 32;
        if (i13 != i14) {
            int i15 = i14 - i13;
            int i16 = iArr[0] >>> i15;
            for (int i17 = 1; i17 < i11; i17++) {
                int i18 = iArr[i17];
                iArr[i17 - 1] = i16 | (i18 << (32 - i15));
                i16 = i18 >>> i15;
            }
            iArr[i10] = i16;
        }
        this.f33003a = iArr;
    }

    public final void j(int i10) {
        int[] iArr = this.f33003a;
        int i11 = i10 / 32;
        iArr[i11] = (1 << (i10 & 31)) | iArr[i11];
    }

    public final String toString() {
        int i10 = this.f33004b;
        StringBuilder sb = new StringBuilder((i10 / 8) + i10 + 1);
        for (int i11 = 0; i11 < this.f33004b; i11++) {
            if ((i11 & 7) == 0) {
                sb.append(' ');
            }
            sb.append(d(i11) ? 'X' : '.');
        }
        return sb.toString();
    }

    public a(int i10) {
        this.f33004b = i10;
        this.f33003a = new int[(i10 + 31) / 32];
    }
}
