package d.e;

import kotlinx.serialization.json.internal.AbstractJsonLexerKt;

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

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

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

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

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

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

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

    public void b() {
        int i2 = this.f2187p;
        Object[] objArr = this.f2186o;
        for (int i3 = 0; i3 < i2; i3++) {
            objArr[i3] = null;
        }
        this.f2187p = 0;
        this.f2184m = false;
    }

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

    public final void d() {
        int i2 = this.f2187p;
        long[] jArr = this.f2185n;
        Object[] objArr = this.f2186o;
        int i3 = 0;
        for (int i4 = 0; i4 < i2; i4++) {
            Object obj = objArr[i4];
            if (obj != f2183f) {
                if (i4 != i3) {
                    jArr[i3] = jArr[i4];
                    objArr[i3] = obj;
                    objArr[i4] = null;
                }
                i3++;
            }
        }
        this.f2184m = false;
        this.f2187p = i3;
    }

    public E f(long j2) {
        return g(j2, null);
    }

    public E g(long j2, E e2) {
        int iB = d.b(this.f2185n, this.f2187p, j2);
        if (iB >= 0) {
            Object[] objArr = this.f2186o;
            if (objArr[iB] != f2183f) {
                return (E) objArr[iB];
            }
        }
        return e2;
    }

    public void i(long j2, E e2) {
        int iB = d.b(this.f2185n, this.f2187p, j2);
        if (iB >= 0) {
            this.f2186o[iB] = e2;
            return;
        }
        int i2 = ~iB;
        int i3 = this.f2187p;
        if (i2 < i3) {
            Object[] objArr = this.f2186o;
            if (objArr[i2] == f2183f) {
                this.f2185n[i2] = j2;
                objArr[i2] = e2;
                return;
            }
        }
        if (this.f2184m && i3 >= this.f2185n.length) {
            d();
            i2 = ~d.b(this.f2185n, this.f2187p, j2);
        }
        int i4 = this.f2187p;
        if (i4 >= this.f2185n.length) {
            int iF = d.f(i4 + 1);
            long[] jArr = new long[iF];
            Object[] objArr2 = new Object[iF];
            long[] jArr2 = this.f2185n;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr3 = this.f2186o;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f2185n = jArr;
            this.f2186o = objArr2;
        }
        int i5 = this.f2187p;
        if (i5 - i2 != 0) {
            long[] jArr3 = this.f2185n;
            int i6 = i2 + 1;
            System.arraycopy(jArr3, i2, jArr3, i6, i5 - i2);
            Object[] objArr4 = this.f2186o;
            System.arraycopy(objArr4, i2, objArr4, i6, this.f2187p - i2);
        }
        this.f2185n[i2] = j2;
        this.f2186o[i2] = e2;
        this.f2187p++;
    }

    public int j() {
        if (this.f2184m) {
            d();
        }
        return this.f2187p;
    }

    public E k(int i2) {
        if (this.f2184m) {
            d();
        }
        return (E) this.f2186o[i2];
    }

    public String toString() {
        if (j() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f2187p * 28);
        sb.append(AbstractJsonLexerKt.BEGIN_OBJ);
        for (int i2 = 0; i2 < this.f2187p; i2++) {
            if (i2 > 0) {
                sb.append(", ");
            }
            if (this.f2184m) {
                d();
            }
            sb.append(this.f2185n[i2]);
            sb.append('=');
            E eK = k(i2);
            if (eK != this) {
                sb.append(eK);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append(AbstractJsonLexerKt.END_OBJ);
        return sb.toString();
    }
}
