package c.b;

/* 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 f5166b = new Object();

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

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

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

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

    public void b(int i2, E e2) {
        int i3 = this.f5169e;
        if (i3 != 0 && i2 <= this.f5167c[i3 - 1]) {
            e(i2, e2);
            return;
        }
        if (i3 >= this.f5167c.length) {
            int iE = d.e(i3 + 1);
            int[] iArr = new int[iE];
            Object[] objArr = new Object[iE];
            int[] iArr2 = this.f5167c;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr2 = this.f5168d;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f5167c = iArr;
            this.f5168d = objArr;
        }
        this.f5167c[i3] = i2;
        this.f5168d[i3] = e2;
        this.f5169e = i3 + 1;
    }

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

    public E d(int i2, E e2) {
        int iA = d.a(this.f5167c, this.f5169e, i2);
        if (iA >= 0) {
            Object[] objArr = this.f5168d;
            if (objArr[iA] != f5166b) {
                return (E) objArr[iA];
            }
        }
        return e2;
    }

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

    public int f() {
        return this.f5169e;
    }

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

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