package b.d;

/* JADX INFO: loaded from: classes.dex */
public class i<E> implements Cloneable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Object f690a = new Object();

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object[] f692c;

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

    public i() {
        int iE = d.e(10);
        this.f691b = new int[iE];
        this.f692c = new Object[iE];
    }

    public void a(int i, E e2) {
        int i2 = this.f693d;
        if (i2 != 0 && i <= this.f691b[i2 - 1]) {
            d(i, e2);
            return;
        }
        if (i2 >= this.f691b.length) {
            int iE = d.e(i2 + 1);
            int[] iArr = new int[iE];
            Object[] objArr = new Object[iE];
            int[] iArr2 = this.f691b;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr2 = this.f692c;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f691b = iArr;
            this.f692c = objArr;
        }
        this.f691b[i2] = i;
        this.f692c[i2] = e2;
        this.f693d = i2 + 1;
    }

    /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
    public i<E> clone() {
        try {
            i<E> iVar = (i) super.clone();
            iVar.f691b = (int[]) this.f691b.clone();
            iVar.f692c = (Object[]) this.f692c.clone();
            return iVar;
        } catch (CloneNotSupportedException e2) {
            throw new AssertionError(e2);
        }
    }

    public E c(int i, E e2) {
        int iA = d.a(this.f691b, this.f693d, i);
        if (iA >= 0) {
            Object[] objArr = this.f692c;
            if (objArr[iA] != f690a) {
                return (E) objArr[iA];
            }
        }
        return e2;
    }

    public void d(int i, E e2) {
        int iA = d.a(this.f691b, this.f693d, i);
        if (iA >= 0) {
            this.f692c[iA] = e2;
            return;
        }
        int i2 = ~iA;
        int i3 = this.f693d;
        if (i2 < i3) {
            Object[] objArr = this.f692c;
            if (objArr[i2] == f690a) {
                this.f691b[i2] = i;
                objArr[i2] = e2;
                return;
            }
        }
        if (i3 >= this.f691b.length) {
            int iE = d.e(i3 + 1);
            int[] iArr = new int[iE];
            Object[] objArr2 = new Object[iE];
            int[] iArr2 = this.f691b;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr3 = this.f692c;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f691b = iArr;
            this.f692c = objArr2;
        }
        int i4 = this.f693d - i2;
        if (i4 != 0) {
            int[] iArr3 = this.f691b;
            int i5 = i2 + 1;
            System.arraycopy(iArr3, i2, iArr3, i5, i4);
            Object[] objArr4 = this.f692c;
            System.arraycopy(objArr4, i2, objArr4, i5, this.f693d - i2);
        }
        this.f691b[i2] = i;
        this.f692c[i2] = e2;
        this.f693d++;
    }

    public int e() {
        return this.f693d;
    }

    public E f(int i) {
        return (E) this.f692c[i];
    }

    public String toString() {
        if (e() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f693d * 28);
        sb.append('{');
        for (int i = 0; i < this.f693d; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(this.f691b[i]);
            sb.append('=');
            E eF = f(i);
            if (eF != this) {
                sb.append(eF);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}
