package c.b;

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

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

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

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

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

    public e() {
        int iF = d.f(10);
        this.f5134d = new long[iF];
        this.f5135e = 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.f5134d = (long[]) this.f5134d.clone();
            eVar.f5135e = (Object[]) this.f5135e.clone();
            return eVar;
        } catch (CloneNotSupportedException e2) {
            throw new AssertionError(e2);
        }
    }

    public final void c() {
        int i2 = this.f5136f;
        long[] jArr = this.f5134d;
        Object[] objArr = this.f5135e;
        int i3 = 0;
        for (int i4 = 0; i4 < i2; i4++) {
            Object obj = objArr[i4];
            if (obj != f5132b) {
                if (i4 != i3) {
                    jArr[i3] = jArr[i4];
                    objArr[i3] = obj;
                    objArr[i4] = null;
                }
                i3++;
            }
        }
        this.f5133c = false;
        this.f5136f = i3;
    }

    public E d(long j2, E e2) {
        int iB = d.b(this.f5134d, this.f5136f, j2);
        if (iB >= 0) {
            Object[] objArr = this.f5135e;
            if (objArr[iB] != f5132b) {
                return (E) objArr[iB];
            }
        }
        return e2;
    }

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

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