package o;

import java.util.Collection;
import java.util.List;
import java.util.RandomAccess;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.iR, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1479iR implements RandomAccess {
    public Object[] l;
    public SQ m;
    public int n = 0;

    public C1479iR(Object[] objArr) {
        this.l = objArr;
    }

    public final void a(int i, Object obj) {
        int i2 = this.n + 1;
        if (this.l.length < i2) {
            m(i2);
        }
        Object[] objArr = this.l;
        int i3 = this.n;
        if (i != i3) {
            System.arraycopy(objArr, i, objArr, i + 1, i3 - i);
        }
        objArr[i] = obj;
        this.n++;
    }

    public final void b(Object obj) {
        int i = this.n + 1;
        if (this.l.length < i) {
            m(i);
        }
        Object[] objArr = this.l;
        int i2 = this.n;
        objArr[i2] = obj;
        this.n = i2 + 1;
    }

    public final void c(int i, List list) {
        if (list.isEmpty()) {
            return;
        }
        int size = list.size();
        int i2 = this.n + size;
        if (this.l.length < i2) {
            m(i2);
        }
        Object[] objArr = this.l;
        int i3 = this.n;
        if (i != i3) {
            System.arraycopy(objArr, i, objArr, i + size, i3 - i);
        }
        int size2 = list.size();
        for (int i4 = 0; i4 < size2; i4++) {
            objArr[i + i4] = list.get(i4);
        }
        this.n += size;
    }

    public final void d(int i, C1479iR c1479iR) {
        int i2 = c1479iR.n;
        if (i2 == 0) {
            return;
        }
        int i3 = this.n + i2;
        if (this.l.length < i3) {
            m(i3);
        }
        Object[] objArr = this.l;
        int i4 = this.n;
        if (i != i4) {
            System.arraycopy(objArr, i, objArr, i + i2, i4 - i);
        }
        System.arraycopy(c1479iR.l, 0, objArr, i, i2);
        this.n += i2;
    }

    public final boolean e(int i, Collection collection) {
        int i2 = 0;
        if (collection.isEmpty()) {
            return false;
        }
        int size = collection.size();
        int i3 = this.n + size;
        if (this.l.length < i3) {
            m(i3);
        }
        Object[] objArr = this.l;
        int i4 = this.n;
        if (i != i4) {
            System.arraycopy(objArr, i, objArr, i + size, i4 - i);
        }
        for (Object obj : collection) {
            int i5 = i2 + 1;
            if (i2 < 0) {
                AbstractC0008Ai.V();
                throw null;
            }
            objArr[i2 + i] = obj;
            i2 = i5;
        }
        this.n += size;
        return true;
    }

    public final List f() {
        SQ sq = this.m;
        if (sq != null) {
            return sq;
        }
        SQ sq2 = new SQ(1, this);
        this.m = sq2;
        return sq2;
    }

    public final void h() {
        Object[] objArr = this.l;
        int i = this.n;
        for (int i2 = 0; i2 < i; i2++) {
            objArr[i2] = null;
        }
        this.n = 0;
    }

    public final boolean i(Object obj) {
        int i = this.n - 1;
        if (i >= 0) {
            for (int i2 = 0; !F3.c(this.l[i2], obj); i2++) {
                if (i2 != i) {
                }
            }
            return true;
        }
        return false;
    }

    public final boolean j(Object obj) {
        Object[] objArr = this.l;
        int i = this.n;
        int i2 = 0;
        while (true) {
            if (i2 >= i) {
                i2 = -1;
                break;
            }
            if (F3.c(obj, objArr[i2])) {
                break;
            }
            i2++;
        }
        if (i2 < 0) {
            return false;
        }
        k(i2);
        return true;
    }

    public final Object k(int i) {
        Object[] objArr = this.l;
        Object obj = objArr[i];
        int i2 = this.n;
        if (i != i2 - 1) {
            int i3 = i + 1;
            System.arraycopy(objArr, i3, objArr, i, i2 - i3);
        }
        int i4 = this.n - 1;
        this.n = i4;
        objArr[i4] = null;
        return obj;
    }

    public final void l(int i, int i2) {
        if (i2 > i) {
            int i3 = this.n;
            if (i2 < i3) {
                Object[] objArr = this.l;
                System.arraycopy(objArr, i2, objArr, i, i3 - i2);
            }
            int i4 = this.n;
            int i5 = i4 - (i2 - i);
            int i6 = i4 - 1;
            if (i5 <= i6) {
                int i7 = i5;
                while (true) {
                    this.l[i7] = null;
                    if (i7 == i6) {
                        break;
                    } else {
                        i7++;
                    }
                }
            }
            this.n = i5;
        }
    }

    public final void m(int i) {
        Object[] objArr = this.l;
        int length = objArr.length;
        Object[] objArr2 = new Object[Math.max(i, length * 2)];
        System.arraycopy(objArr, 0, objArr2, 0, length);
        this.l = objArr2;
    }
}
