package c.d;

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

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

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

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

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

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

    public void a(int i2, E e2) {
        int i3 = this.f1061g;
        if (i3 != 0 && i2 <= this.f1059e[i3 - 1]) {
            d(i2, e2);
            return;
        }
        if (i3 >= this.f1059e.length) {
            int iE = d.e(i3 + 1);
            int[] iArr = new int[iE];
            Object[] objArr = new Object[iE];
            int[] iArr2 = this.f1059e;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr2 = this.f1060f;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f1059e = iArr;
            this.f1060f = objArr;
        }
        this.f1059e[i3] = i2;
        this.f1060f[i3] = e2;
        this.f1061g = i3 + 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.f1059e = (int[]) this.f1059e.clone();
            iVar.f1060f = (Object[]) this.f1060f.clone();
            return iVar;
        } catch (CloneNotSupportedException e2) {
            throw new AssertionError(e2);
        }
    }

    public E c(int i2, E e2) {
        int iA = d.a(this.f1059e, this.f1061g, i2);
        if (iA >= 0) {
            Object[] objArr = this.f1060f;
            if (objArr[iA] != f1058b) {
                return (E) objArr[iA];
            }
        }
        return e2;
    }

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

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

    public E g(int i2) {
        return (E) this.f1060f[i2];
    }

    public String toString() {
        if (e() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f1061g * 28);
        sb.append('{');
        for (int i2 = 0; i2 < this.f1061g; i2++) {
            if (i2 > 0) {
                sb.append(", ");
            }
            sb.append(this.f1059e[i2]);
            sb.append('=');
            E eG = g(i2);
            if (eG != this) {
                sb.append(eG);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}
