package p037m;

/* renamed from: m.d */
/* loaded from: classes.dex */
public class C1449d<E> implements Cloneable {

    /* renamed from: h */
    public static final Object f3165h = new Object();

    /* renamed from: d */
    public boolean f3166d;

    /* renamed from: e */
    public long[] f3167e;

    /* renamed from: f */
    public Object[] f3168f;

    /* renamed from: g */
    public int f3169g;

    public C1449d() {
        this(10);
    }

    public C1449d(int i) {
        this.f3166d = false;
        if (i == 0) {
            this.f3167e = C1448c.f3163b;
            this.f3168f = C1448c.f3164c;
            return;
        }
        int m1369f = C1448c.m1369f(i);
        this.f3167e = new long[m1369f];
        this.f3168f = new Object[m1369f];
    }

    /* renamed from: a */
    public void m1368a(long j, E e) {
        int i = this.f3169g;
        if (i != 0 && j <= this.f3167e[i - 1]) {
            m1361h(j, e);
            return;
        }
        if (this.f3166d && i >= this.f3167e.length) {
            m1365d();
        }
        int i2 = this.f3169g;
        if (i2 >= this.f3167e.length) {
            int m1369f = C1448c.m1369f(i2 + 1);
            long[] jArr = new long[m1369f];
            Object[] objArr = new Object[m1369f];
            long[] jArr2 = this.f3167e;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr2 = this.f3168f;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f3167e = jArr;
            this.f3168f = objArr;
        }
        this.f3167e[i2] = j;
        this.f3168f[i2] = e;
        this.f3169g = i2 + 1;
    }

    /* renamed from: b */
    public void m1367b() {
        int i = this.f3169g;
        Object[] objArr = this.f3168f;
        for (int i2 = 0; i2 < i; i2++) {
            objArr[i2] = null;
        }
        this.f3169g = 0;
        this.f3166d = false;
    }

    /* renamed from: c */
    public C1449d<E> clone() {
        try {
            C1449d<E> c1449d = (C1449d) super.clone();
            c1449d.f3167e = (long[]) this.f3167e.clone();
            c1449d.f3168f = (Object[]) this.f3168f.clone();
            return c1449d;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: d */
    public final void m1365d() {
        int i = this.f3169g;
        long[] jArr = this.f3167e;
        Object[] objArr = this.f3168f;
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            Object obj = objArr[i3];
            if (obj != f3165h) {
                if (i3 != i2) {
                    jArr[i2] = jArr[i3];
                    objArr[i2] = obj;
                    objArr[i3] = null;
                }
                i2++;
            }
        }
        this.f3166d = false;
        this.f3169g = i2;
    }

    /* renamed from: e */
    public E m1364e(long j) {
        return m1363f(j, null);
    }

    /* renamed from: f */
    public E m1363f(long j, E e) {
        E e2;
        int m1373b = C1448c.m1373b(this.f3167e, this.f3169g, j);
        return (m1373b < 0 || (e2 = (E) this.f3168f[m1373b]) == f3165h) ? e : e2;
    }

    /* renamed from: g */
    public long m1362g(int i) {
        if (this.f3166d) {
            m1365d();
        }
        return this.f3167e[i];
    }

    /* renamed from: h */
    public void m1361h(long j, E e) {
        int m1373b = C1448c.m1373b(this.f3167e, this.f3169g, j);
        if (m1373b >= 0) {
            this.f3168f[m1373b] = e;
            return;
        }
        int i = m1373b ^ (-1);
        int i2 = this.f3169g;
        if (i < i2) {
            Object[] objArr = this.f3168f;
            if (objArr[i] == f3165h) {
                this.f3167e[i] = j;
                objArr[i] = e;
                return;
            }
        }
        if (this.f3166d && i2 >= this.f3167e.length) {
            m1365d();
            i = C1448c.m1373b(this.f3167e, this.f3169g, j) ^ (-1);
        }
        int i3 = this.f3169g;
        if (i3 >= this.f3167e.length) {
            int m1369f = C1448c.m1369f(i3 + 1);
            long[] jArr = new long[m1369f];
            Object[] objArr2 = new Object[m1369f];
            long[] jArr2 = this.f3167e;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr3 = this.f3168f;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f3167e = jArr;
            this.f3168f = objArr2;
        }
        int i4 = this.f3169g;
        if (i4 - i != 0) {
            long[] jArr3 = this.f3167e;
            int i5 = i + 1;
            System.arraycopy(jArr3, i, jArr3, i5, i4 - i);
            Object[] objArr4 = this.f3168f;
            System.arraycopy(objArr4, i, objArr4, i5, this.f3169g - i);
        }
        this.f3167e[i] = j;
        this.f3168f[i] = e;
        this.f3169g++;
    }

    /* renamed from: i */
    public void m1360i(long j) {
        int m1373b = C1448c.m1373b(this.f3167e, this.f3169g, j);
        if (m1373b >= 0) {
            Object[] objArr = this.f3168f;
            Object obj = objArr[m1373b];
            Object obj2 = f3165h;
            if (obj != obj2) {
                objArr[m1373b] = obj2;
                this.f3166d = true;
            }
        }
    }

    /* renamed from: j */
    public int m1359j() {
        if (this.f3166d) {
            m1365d();
        }
        return this.f3169g;
    }

    /* renamed from: k */
    public E m1358k(int i) {
        if (this.f3166d) {
            m1365d();
        }
        return (E) this.f3168f[i];
    }

    public String toString() {
        if (m1359j() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f3169g * 28);
        sb.append('{');
        for (int i = 0; i < this.f3169g; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(m1362g(i));
            sb.append('=');
            E m1358k = m1358k(i);
            if (m1358k != this) {
                sb.append(m1358k);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }
}