package o;

import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ca0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0914ca0 implements Cloneable {
    public /* synthetic */ int[] l;
    public /* synthetic */ Object[] m;
    public /* synthetic */ int n;

    public C0914ca0(int i) {
        int i2;
        int i3 = 4;
        while (true) {
            i2 = 40;
            if (i3 >= 32) {
                break;
            }
            int i4 = (1 << i3) - 12;
            if (40 <= i4) {
                i2 = i4;
                break;
            }
            i3++;
        }
        int i5 = i2 / 4;
        this.l = new int[i5];
        this.m = new Object[i5];
    }

    public final void a(int i, Object obj) {
        int i2 = this.n;
        if (i2 != 0 && i <= this.l[i2 - 1]) {
            d(i, obj);
            return;
        }
        if (i2 >= this.l.length) {
            int i3 = (i2 + 1) * 4;
            int i4 = 4;
            while (true) {
                if (i4 >= 32) {
                    break;
                }
                int i5 = (1 << i4) - 12;
                if (i3 <= i5) {
                    i3 = i5;
                    break;
                }
                i4++;
            }
            int i6 = i3 / 4;
            this.l = Arrays.copyOf(this.l, i6);
            this.m = Arrays.copyOf(this.m, i6);
        }
        this.l[i2] = i;
        this.m[i2] = obj;
        this.n = i2 + 1;
    }

    /* renamed from: b, reason: merged with bridge method [inline-methods] */
    public final C0914ca0 clone() {
        C0914ca0 c0914ca0 = (C0914ca0) super.clone();
        c0914ca0.l = (int[]) this.l.clone();
        c0914ca0.m = (Object[]) this.m.clone();
        return c0914ca0;
    }

    public final Object c(int i) {
        Object obj;
        int iC = AbstractC0940cn0.c(this.n, i, this.l);
        if (iC < 0 || (obj = this.m[iC]) == AbstractC0662Zn.i) {
            return null;
        }
        return obj;
    }

    public final void d(int i, Object obj) {
        int iC = AbstractC0940cn0.c(this.n, i, this.l);
        if (iC >= 0) {
            this.m[iC] = obj;
            return;
        }
        int i2 = ~iC;
        int i3 = this.n;
        if (i2 < i3) {
            Object[] objArr = this.m;
            if (objArr[i2] == AbstractC0662Zn.i) {
                this.l[i2] = i;
                objArr[i2] = obj;
                return;
            }
        }
        if (i3 >= this.l.length) {
            int i4 = (i3 + 1) * 4;
            int i5 = 4;
            while (true) {
                if (i5 >= 32) {
                    break;
                }
                int i6 = (1 << i5) - 12;
                if (i4 <= i6) {
                    i4 = i6;
                    break;
                }
                i5++;
            }
            int i7 = i4 / 4;
            this.l = Arrays.copyOf(this.l, i7);
            this.m = Arrays.copyOf(this.m, i7);
        }
        int i8 = this.n;
        if (i8 - i2 != 0) {
            int[] iArr = this.l;
            int i9 = i2 + 1;
            AbstractC2219q9.I(i9, i2, i8, iArr, iArr);
            Object[] objArr2 = this.m;
            AbstractC2219q9.J(i9, i2, this.n, objArr2, objArr2);
        }
        this.l[i2] = i;
        this.m[i2] = obj;
        this.n++;
    }

    public final Object e(int i) {
        Object[] objArr = this.m;
        if (i < objArr.length) {
            return objArr[i];
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final String toString() {
        int i = this.n;
        if (i <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(i * 28);
        sb.append('{');
        int i2 = this.n;
        for (int i3 = 0; i3 < i2; i3++) {
            if (i3 > 0) {
                sb.append(", ");
            }
            sb.append(this.l[i3]);
            sb.append('=');
            Object objE = e(i3);
            if (objE != this) {
                sb.append(objE);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}
