package b.d;

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

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

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

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

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

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

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

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

    public final void b() {
        int i = this.f662e;
        long[] jArr = this.f660c;
        Object[] objArr = this.f661d;
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            Object obj = objArr[i3];
            if (obj != f658a) {
                if (i3 != i2) {
                    jArr[i2] = jArr[i3];
                    objArr[i2] = obj;
                    objArr[i3] = null;
                }
                i2++;
            }
        }
        this.f659b = false;
        this.f662e = i2;
    }

    public E c(long j, E e2) {
        int iB = d.b(this.f660c, this.f662e, j);
        if (iB >= 0) {
            Object[] objArr = this.f661d;
            if (objArr[iB] != f658a) {
                return (E) objArr[iB];
            }
        }
        return e2;
    }

    public void d(long j, E e2) {
        int iB = d.b(this.f660c, this.f662e, j);
        if (iB >= 0) {
            this.f661d[iB] = e2;
            return;
        }
        int i = ~iB;
        int i2 = this.f662e;
        if (i < i2) {
            Object[] objArr = this.f661d;
            if (objArr[i] == f658a) {
                this.f660c[i] = j;
                objArr[i] = e2;
                return;
            }
        }
        if (this.f659b && i2 >= this.f660c.length) {
            b();
            i = ~d.b(this.f660c, this.f662e, j);
        }
        int i3 = this.f662e;
        if (i3 >= this.f660c.length) {
            int iF = d.f(i3 + 1);
            long[] jArr = new long[iF];
            Object[] objArr2 = new Object[iF];
            long[] jArr2 = this.f660c;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr3 = this.f661d;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f660c = jArr;
            this.f661d = objArr2;
        }
        int i4 = this.f662e;
        if (i4 - i != 0) {
            long[] jArr3 = this.f660c;
            int i5 = i + 1;
            System.arraycopy(jArr3, i, jArr3, i5, i4 - i);
            Object[] objArr4 = this.f661d;
            System.arraycopy(objArr4, i, objArr4, i5, this.f662e - i);
        }
        this.f660c[i] = j;
        this.f661d[i] = e2;
        this.f662e++;
    }

    public String toString() {
        if (this.f659b) {
            b();
        }
        int i = this.f662e;
        if (i <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(i * 28);
        sb.append('{');
        for (int i2 = 0; i2 < this.f662e; i2++) {
            if (i2 > 0) {
                sb.append(", ");
            }
            if (this.f659b) {
                b();
            }
            sb.append(this.f660c[i2]);
            sb.append('=');
            if (this.f659b) {
                b();
            }
            Object obj = this.f661d[i2];
            if (obj != this) {
                sb.append(obj);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}
