package p037m;

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

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

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

    /* renamed from: e */
    public int[] f3202e;

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

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

    public C1458h() {
        this(10);
    }

    public C1458h(int i) {
        this.f3201d = false;
        if (i == 0) {
            this.f3202e = C1448c.f3162a;
            this.f3203f = C1448c.f3164c;
            return;
        }
        int m1370e = C1448c.m1370e(i);
        this.f3202e = new int[m1370e];
        this.f3203f = new Object[m1370e];
    }

    /* renamed from: a */
    public void m1318a(int i, E e) {
        int i2 = this.f3204g;
        if (i2 != 0 && i <= this.f3202e[i2 - 1]) {
            m1311h(i, e);
            return;
        }
        if (this.f3201d && i2 >= this.f3202e.length) {
            m1315d();
        }
        int i3 = this.f3204g;
        if (i3 >= this.f3202e.length) {
            int m1370e = C1448c.m1370e(i3 + 1);
            int[] iArr = new int[m1370e];
            Object[] objArr = new Object[m1370e];
            int[] iArr2 = this.f3202e;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr2 = this.f3203f;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f3202e = iArr;
            this.f3203f = objArr;
        }
        this.f3202e[i3] = i;
        this.f3203f[i3] = e;
        this.f3204g = i3 + 1;
    }

    /* renamed from: b */
    public void m1317b() {
        int i = this.f3204g;
        Object[] objArr = this.f3203f;
        for (int i2 = 0; i2 < i; i2++) {
            objArr[i2] = null;
        }
        this.f3204g = 0;
        this.f3201d = false;
    }

    /* renamed from: c */
    public C1458h<E> clone() {
        try {
            C1458h<E> c1458h = (C1458h) super.clone();
            c1458h.f3202e = (int[]) this.f3202e.clone();
            c1458h.f3203f = (Object[]) this.f3203f.clone();
            return c1458h;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: d */
    public final void m1315d() {
        int i = this.f3204g;
        int[] iArr = this.f3202e;
        Object[] objArr = this.f3203f;
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            Object obj = objArr[i3];
            if (obj != f3200h) {
                if (i3 != i2) {
                    iArr[i2] = iArr[i3];
                    objArr[i2] = obj;
                    objArr[i3] = null;
                }
                i2++;
            }
        }
        this.f3201d = false;
        this.f3204g = i2;
    }

    /* renamed from: e */
    public E m1314e(int i) {
        return m1313f(i, null);
    }

    /* renamed from: f */
    public E m1313f(int i, E e) {
        E e2;
        int m1374a = C1448c.m1374a(this.f3202e, this.f3204g, i);
        return (m1374a < 0 || (e2 = (E) this.f3203f[m1374a]) == f3200h) ? e : e2;
    }

    /* renamed from: g */
    public int m1312g(int i) {
        if (this.f3201d) {
            m1315d();
        }
        return this.f3202e[i];
    }

    /* renamed from: h */
    public void m1311h(int i, E e) {
        int m1374a = C1448c.m1374a(this.f3202e, this.f3204g, i);
        if (m1374a >= 0) {
            this.f3203f[m1374a] = e;
            return;
        }
        int i2 = m1374a ^ (-1);
        int i3 = this.f3204g;
        if (i2 < i3) {
            Object[] objArr = this.f3203f;
            if (objArr[i2] == f3200h) {
                this.f3202e[i2] = i;
                objArr[i2] = e;
                return;
            }
        }
        if (this.f3201d && i3 >= this.f3202e.length) {
            m1315d();
            i2 = C1448c.m1374a(this.f3202e, this.f3204g, i) ^ (-1);
        }
        int i4 = this.f3204g;
        if (i4 >= this.f3202e.length) {
            int m1370e = C1448c.m1370e(i4 + 1);
            int[] iArr = new int[m1370e];
            Object[] objArr2 = new Object[m1370e];
            int[] iArr2 = this.f3202e;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr3 = this.f3203f;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f3202e = iArr;
            this.f3203f = objArr2;
        }
        int i5 = this.f3204g;
        if (i5 - i2 != 0) {
            int[] iArr3 = this.f3202e;
            int i6 = i2 + 1;
            System.arraycopy(iArr3, i2, iArr3, i6, i5 - i2);
            Object[] objArr4 = this.f3203f;
            System.arraycopy(objArr4, i2, objArr4, i6, this.f3204g - i2);
        }
        this.f3202e[i2] = i;
        this.f3203f[i2] = e;
        this.f3204g++;
    }

    /* renamed from: i */
    public int m1310i() {
        if (this.f3201d) {
            m1315d();
        }
        return this.f3204g;
    }

    /* renamed from: j */
    public E m1309j(int i) {
        if (this.f3201d) {
            m1315d();
        }
        return (E) this.f3203f[i];
    }

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