package c.d;

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f5120c = false;

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

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

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

    public e() {
        int iF = d.f(10);
        this.f5121d = new long[iF];
        this.f5122e = new Object[iF];
    }

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

    public final void c() {
        int i2 = this.f5123f;
        long[] jArr = this.f5121d;
        Object[] objArr = this.f5122e;
        int i3 = 0;
        for (int i4 = 0; i4 < i2; i4++) {
            Object obj = objArr[i4];
            if (obj != f5119b) {
                if (i4 != i3) {
                    jArr[i3] = jArr[i4];
                    objArr[i3] = obj;
                    objArr[i4] = null;
                }
                i3++;
            }
        }
        this.f5120c = false;
        this.f5123f = i3;
    }

    public E d(long j2, E e2) {
        int iB = d.b(this.f5121d, this.f5123f, j2);
        if (iB >= 0) {
            Object[] objArr = this.f5122e;
            if (objArr[iB] != f5119b) {
                return (E) objArr[iB];
            }
        }
        return e2;
    }

    public void e(long j2, E e2) {
        int iB = d.b(this.f5121d, this.f5123f, j2);
        if (iB >= 0) {
            this.f5122e[iB] = e2;
            return;
        }
        int i2 = ~iB;
        int i3 = this.f5123f;
        if (i2 < i3) {
            Object[] objArr = this.f5122e;
            if (objArr[i2] == f5119b) {
                this.f5121d[i2] = j2;
                objArr[i2] = e2;
                return;
            }
        }
        if (this.f5120c && i3 >= this.f5121d.length) {
            c();
            i2 = ~d.b(this.f5121d, this.f5123f, j2);
        }
        int i4 = this.f5123f;
        if (i4 >= this.f5121d.length) {
            int iF = d.f(i4 + 1);
            long[] jArr = new long[iF];
            Object[] objArr2 = new Object[iF];
            long[] jArr2 = this.f5121d;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr3 = this.f5122e;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f5121d = jArr;
            this.f5122e = objArr2;
        }
        int i5 = this.f5123f;
        if (i5 - i2 != 0) {
            long[] jArr3 = this.f5121d;
            int i6 = i2 + 1;
            System.arraycopy(jArr3, i2, jArr3, i6, i5 - i2);
            Object[] objArr4 = this.f5122e;
            System.arraycopy(objArr4, i2, objArr4, i6, this.f5123f - i2);
        }
        this.f5121d[i2] = j2;
        this.f5122e[i2] = e2;
        this.f5123f++;
    }

    public String toString() {
        if (this.f5120c) {
            c();
        }
        int i2 = this.f5123f;
        if (i2 <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(i2 * 28);
        sb.append('{');
        for (int i3 = 0; i3 < this.f5123f; i3++) {
            if (i3 > 0) {
                sb.append(", ");
            }
            if (this.f5120c) {
                c();
            }
            sb.append(this.f5121d[i3]);
            sb.append('=');
            if (this.f5120c) {
                c();
            }
            Object obj = this.f5122e[i3];
            if (obj != this) {
                sb.append(obj);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}
