package X6FRs_4.Mqv2r_3;
/* compiled from: LongSparseArray.java */
/* loaded from: classes.dex */
public class Mqv2r_3<E> implements Cloneable {
    public static final Object KQgRr5e_0 = new Object();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public int f1010KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public long[] f1011KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Object[] f1012KQgRr5e_0;
    public boolean QxJ9d_1;

    public Mqv2r_3() {
        this(10);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public Mqv2r_3<E> clone() {
        try {
            Mqv2r_3<E> mqv2r_3 = (Mqv2r_3) super.clone();
            mqv2r_3.f1011KQgRr5e_0 = (long[]) this.f1011KQgRr5e_0.clone();
            mqv2r_3.f1012KQgRr5e_0 = (Object[]) this.f1012KQgRr5e_0.clone();
            return mqv2r_3;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }

    public final void QxJ9d_1() {
        int i = this.f1010KQgRr5e_0;
        long[] jArr = this.f1011KQgRr5e_0;
        Object[] objArr = this.f1012KQgRr5e_0;
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            Object obj = objArr[i3];
            if (obj != KQgRr5e_0) {
                if (i3 != i2) {
                    jArr[i2] = jArr[i3];
                    objArr[i2] = obj;
                    objArr[i3] = null;
                }
                i2++;
            }
        }
        this.QxJ9d_1 = false;
        this.f1010KQgRr5e_0 = i2;
    }

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

    public Mqv2r_3(int i) {
        this.QxJ9d_1 = false;
        if (i == 0) {
            this.f1011KQgRr5e_0 = PGPF6hQ_2.f1013KQgRr5e_0;
            this.f1012KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
        } else {
            int PGPF6hQ_2 = PGPF6hQ_2.PGPF6hQ_2(i);
            this.f1011KQgRr5e_0 = new long[PGPF6hQ_2];
            this.f1012KQgRr5e_0 = new Object[PGPF6hQ_2];
        }
        this.f1010KQgRr5e_0 = 0;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public E m505KQgRr5e_0(long j) {
        return KQgRr5e_0(j, (long) null);
    }

    public E KQgRr5e_0(long j, E e) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f1011KQgRr5e_0, this.f1010KQgRr5e_0, j);
        if (KQgRr5e_02 >= 0) {
            Object[] objArr = this.f1012KQgRr5e_0;
            if (objArr[KQgRr5e_02] != KQgRr5e_0) {
                return (E) objArr[KQgRr5e_02];
            }
        }
        return e;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m508KQgRr5e_0(long j) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f1011KQgRr5e_0, this.f1010KQgRr5e_0, j);
        if (KQgRr5e_02 >= 0) {
            Object[] objArr = this.f1012KQgRr5e_0;
            Object obj = objArr[KQgRr5e_02];
            Object obj2 = KQgRr5e_0;
            if (obj != obj2) {
                objArr[KQgRr5e_02] = obj2;
                this.QxJ9d_1 = true;
            }
        }
    }

    public void QxJ9d_1(long j, E e) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f1011KQgRr5e_0, this.f1010KQgRr5e_0, j);
        if (KQgRr5e_02 >= 0) {
            this.f1012KQgRr5e_0[KQgRr5e_02] = e;
            return;
        }
        int i = KQgRr5e_02 ^ (-1);
        if (i < this.f1010KQgRr5e_0) {
            Object[] objArr = this.f1012KQgRr5e_0;
            if (objArr[i] == KQgRr5e_0) {
                this.f1011KQgRr5e_0[i] = j;
                objArr[i] = e;
                return;
            }
        }
        if (this.QxJ9d_1 && this.f1010KQgRr5e_0 >= this.f1011KQgRr5e_0.length) {
            QxJ9d_1();
            i = PGPF6hQ_2.KQgRr5e_0(this.f1011KQgRr5e_0, this.f1010KQgRr5e_0, j) ^ (-1);
        }
        int i2 = this.f1010KQgRr5e_0;
        if (i2 >= this.f1011KQgRr5e_0.length) {
            int PGPF6hQ_2 = PGPF6hQ_2.PGPF6hQ_2(i2 + 1);
            long[] jArr = new long[PGPF6hQ_2];
            Object[] objArr2 = new Object[PGPF6hQ_2];
            long[] jArr2 = this.f1011KQgRr5e_0;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr3 = this.f1012KQgRr5e_0;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f1011KQgRr5e_0 = jArr;
            this.f1012KQgRr5e_0 = objArr2;
        }
        int i3 = this.f1010KQgRr5e_0;
        if (i3 - i != 0) {
            long[] jArr3 = this.f1011KQgRr5e_0;
            int i4 = i + 1;
            System.arraycopy(jArr3, i, jArr3, i4, i3 - i);
            Object[] objArr4 = this.f1012KQgRr5e_0;
            System.arraycopy(objArr4, i, objArr4, i4, this.f1010KQgRr5e_0 - i);
        }
        this.f1011KQgRr5e_0[i] = j;
        this.f1012KQgRr5e_0[i] = e;
        this.f1010KQgRr5e_0++;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m507KQgRr5e_0(int i) {
        Object[] objArr = this.f1012KQgRr5e_0;
        Object obj = objArr[i];
        Object obj2 = KQgRr5e_0;
        if (obj != obj2) {
            objArr[i] = obj2;
            this.QxJ9d_1 = true;
        }
    }

    public int KQgRr5e_0() {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return this.f1010KQgRr5e_0;
    }

    public long KQgRr5e_0(int i) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return this.f1011KQgRr5e_0[i];
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public E m504KQgRr5e_0(int i) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return (E) this.f1012KQgRr5e_0[i];
    }

    public int KQgRr5e_0(long j) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return PGPF6hQ_2.KQgRr5e_0(this.f1011KQgRr5e_0, this.f1010KQgRr5e_0, j);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m506KQgRr5e_0() {
        int i = this.f1010KQgRr5e_0;
        Object[] objArr = this.f1012KQgRr5e_0;
        for (int i2 = 0; i2 < i; i2++) {
            objArr[i2] = null;
        }
        this.f1010KQgRr5e_0 = 0;
        this.QxJ9d_1 = false;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m509KQgRr5e_0(long j, E e) {
        int i = this.f1010KQgRr5e_0;
        if (i != 0 && j <= this.f1011KQgRr5e_0[i - 1]) {
            QxJ9d_1(j, e);
            return;
        }
        if (this.QxJ9d_1 && this.f1010KQgRr5e_0 >= this.f1011KQgRr5e_0.length) {
            QxJ9d_1();
        }
        int i2 = this.f1010KQgRr5e_0;
        if (i2 >= this.f1011KQgRr5e_0.length) {
            int PGPF6hQ_2 = PGPF6hQ_2.PGPF6hQ_2(i2 + 1);
            long[] jArr = new long[PGPF6hQ_2];
            Object[] objArr = new Object[PGPF6hQ_2];
            long[] jArr2 = this.f1011KQgRr5e_0;
            System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
            Object[] objArr2 = this.f1012KQgRr5e_0;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f1011KQgRr5e_0 = jArr;
            this.f1012KQgRr5e_0 = objArr;
        }
        this.f1011KQgRr5e_0[i2] = j;
        this.f1012KQgRr5e_0[i2] = e;
        this.f1010KQgRr5e_0 = i2 + 1;
    }
}
