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

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

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

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

    public FSaI4_7() {
        this(10);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public FSaI4_7<E> clone() {
        try {
            FSaI4_7<E> fSaI4_7 = (FSaI4_7) super.clone();
            fSaI4_7.f998KQgRr5e_0 = (int[]) this.f998KQgRr5e_0.clone();
            fSaI4_7.f999KQgRr5e_0 = (Object[]) this.f999KQgRr5e_0.clone();
            return fSaI4_7;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public void m495QxJ9d_1(int i) {
        m492KQgRr5e_0(i);
    }

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

    public FSaI4_7(int i) {
        this.QxJ9d_1 = false;
        if (i == 0) {
            this.f998KQgRr5e_0 = PGPF6hQ_2.KQgRr5e_0;
            this.f999KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
        } else {
            int QxJ9d_1 = PGPF6hQ_2.QxJ9d_1(i);
            this.f998KQgRr5e_0 = new int[QxJ9d_1];
            this.f999KQgRr5e_0 = new Object[QxJ9d_1];
        }
        this.f997KQgRr5e_0 = 0;
    }

    public final void QxJ9d_1() {
        int i = this.f997KQgRr5e_0;
        int[] iArr = this.f998KQgRr5e_0;
        Object[] objArr = this.f999KQgRr5e_0;
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            Object obj = objArr[i3];
            if (obj != KQgRr5e_0) {
                if (i3 != i2) {
                    iArr[i2] = iArr[i3];
                    objArr[i2] = obj;
                    objArr[i3] = null;
                }
                i2++;
            }
        }
        this.QxJ9d_1 = false;
        this.f997KQgRr5e_0 = i2;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public E m490KQgRr5e_0(int i) {
        return KQgRr5e_0(i, (int) null);
    }

    public E KQgRr5e_0(int i, E e) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f998KQgRr5e_0, this.f997KQgRr5e_0, i);
        if (KQgRr5e_02 >= 0) {
            Object[] objArr = this.f999KQgRr5e_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 m492KQgRr5e_0(int i) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f998KQgRr5e_0, this.f997KQgRr5e_0, i);
        if (KQgRr5e_02 >= 0) {
            Object[] objArr = this.f999KQgRr5e_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(int i, E e) {
        int KQgRr5e_02 = PGPF6hQ_2.KQgRr5e_0(this.f998KQgRr5e_0, this.f997KQgRr5e_0, i);
        if (KQgRr5e_02 >= 0) {
            this.f999KQgRr5e_0[KQgRr5e_02] = e;
            return;
        }
        int i2 = KQgRr5e_02 ^ (-1);
        if (i2 < this.f997KQgRr5e_0) {
            Object[] objArr = this.f999KQgRr5e_0;
            if (objArr[i2] == KQgRr5e_0) {
                this.f998KQgRr5e_0[i2] = i;
                objArr[i2] = e;
                return;
            }
        }
        if (this.QxJ9d_1 && this.f997KQgRr5e_0 >= this.f998KQgRr5e_0.length) {
            QxJ9d_1();
            i2 = PGPF6hQ_2.KQgRr5e_0(this.f998KQgRr5e_0, this.f997KQgRr5e_0, i) ^ (-1);
        }
        int i3 = this.f997KQgRr5e_0;
        if (i3 >= this.f998KQgRr5e_0.length) {
            int QxJ9d_1 = PGPF6hQ_2.QxJ9d_1(i3 + 1);
            int[] iArr = new int[QxJ9d_1];
            Object[] objArr2 = new Object[QxJ9d_1];
            int[] iArr2 = this.f998KQgRr5e_0;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr3 = this.f999KQgRr5e_0;
            System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
            this.f998KQgRr5e_0 = iArr;
            this.f999KQgRr5e_0 = objArr2;
        }
        int i4 = this.f997KQgRr5e_0;
        if (i4 - i2 != 0) {
            int[] iArr3 = this.f998KQgRr5e_0;
            int i5 = i2 + 1;
            System.arraycopy(iArr3, i2, iArr3, i5, i4 - i2);
            Object[] objArr4 = this.f999KQgRr5e_0;
            System.arraycopy(objArr4, i2, objArr4, i5, this.f997KQgRr5e_0 - i2);
        }
        this.f998KQgRr5e_0[i2] = i;
        this.f999KQgRr5e_0[i2] = e;
        this.f997KQgRr5e_0++;
    }

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

    public int KQgRr5e_0(int i) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return PGPF6hQ_2.KQgRr5e_0(this.f998KQgRr5e_0, this.f997KQgRr5e_0, i);
    }

    public int KQgRr5e_0(E e) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        for (int i = 0; i < this.f997KQgRr5e_0; i++) {
            if (this.f999KQgRr5e_0[i] == e) {
                return i;
            }
        }
        return -1;
    }

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

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m493KQgRr5e_0(int i, E e) {
        int i2 = this.f997KQgRr5e_0;
        if (i2 != 0 && i <= this.f998KQgRr5e_0[i2 - 1]) {
            QxJ9d_1(i, e);
            return;
        }
        if (this.QxJ9d_1 && this.f997KQgRr5e_0 >= this.f998KQgRr5e_0.length) {
            QxJ9d_1();
        }
        int i3 = this.f997KQgRr5e_0;
        if (i3 >= this.f998KQgRr5e_0.length) {
            int QxJ9d_1 = PGPF6hQ_2.QxJ9d_1(i3 + 1);
            int[] iArr = new int[QxJ9d_1];
            Object[] objArr = new Object[QxJ9d_1];
            int[] iArr2 = this.f998KQgRr5e_0;
            System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
            Object[] objArr2 = this.f999KQgRr5e_0;
            System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
            this.f998KQgRr5e_0 = iArr;
            this.f999KQgRr5e_0 = objArr;
        }
        this.f998KQgRr5e_0[i3] = i;
        this.f999KQgRr5e_0[i3] = e;
        this.f997KQgRr5e_0 = i3 + 1;
    }

    public int QxJ9d_1(int i) {
        if (this.QxJ9d_1) {
            QxJ9d_1();
        }
        return this.f998KQgRr5e_0[i];
    }

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