package o;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.ListIterator;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.j90, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1555j90 extends Y {
    public static final C1555j90 m = new C1555j90(new Object[0]);
    public final Object[] l;

    public C1555j90(Object[] objArr) {
        this.l = objArr;
        int length = objArr.length;
    }

    @Override // o.AbstractC2864x
    public final int a() {
        return this.l.length;
    }

    @Override // o.Y
    public final Y b(int i, Object obj) {
        Object[] objArr = this.l;
        AbstractC2798wI.i(i, objArr.length);
        if (i == objArr.length) {
            return c(obj);
        }
        if (objArr.length < 32) {
            Object[] objArr2 = new Object[objArr.length + 1];
            AbstractC2219q9.M(0, i, 6, objArr, objArr2);
            AbstractC2219q9.J(i + 1, i, objArr.length, objArr, objArr2);
            objArr2[i] = obj;
            return new C1555j90(objArr2);
        }
        Object[] objArrCopyOf = Arrays.copyOf(objArr, objArr.length);
        AbstractC2219q9.J(i + 1, i, objArr.length - 1, objArr, objArrCopyOf);
        objArrCopyOf[i] = obj;
        Object[] objArr3 = new Object[32];
        objArr3[0] = objArr[31];
        return new MW(objArrCopyOf, objArr3, objArr.length + 1, 0);
    }

    @Override // o.Y
    public final Y c(Object obj) {
        Object[] objArr = this.l;
        if (objArr.length < 32) {
            Object[] objArrCopyOf = Arrays.copyOf(objArr, objArr.length + 1);
            objArrCopyOf[objArr.length] = obj;
            return new C1555j90(objArrCopyOf);
        }
        Object[] objArr2 = new Object[32];
        objArr2[0] = obj;
        return new MW(objArr, objArr2, objArr.length + 1, 0);
    }

    @Override // o.Y
    public final Y d(Collection collection) {
        Object[] objArr = this.l;
        if (collection.size() + objArr.length > 32) {
            NW nwE = e();
            nwE.addAll(collection);
            return nwE.c();
        }
        Object[] objArrCopyOf = Arrays.copyOf(objArr, collection.size() + objArr.length);
        int length = objArr.length;
        Iterator it = collection.iterator();
        while (it.hasNext()) {
            objArrCopyOf[length] = it.next();
            length++;
        }
        return new C1555j90(objArrCopyOf);
    }

    @Override // o.Y
    public final NW e() {
        return new NW(this, null, this.l, 0);
    }

    @Override // o.Y
    public final Y f(X x) {
        Object[] objArr = this.l;
        int length = objArr.length;
        int length2 = objArr.length;
        Object[] objArrCopyOf = objArr;
        boolean z = false;
        for (int i = 0; i < length2; i++) {
            Object obj = objArr[i];
            if (((Boolean) x.g(obj)).booleanValue()) {
                if (!z) {
                    objArrCopyOf = Arrays.copyOf(objArr, objArr.length);
                    z = true;
                    length = i;
                }
            } else if (z) {
                objArrCopyOf[length] = obj;
                length++;
            }
        }
        if (length == objArr.length) {
            return this;
        }
        if (length == 0) {
            return m;
        }
        AbstractC2461sm0.d(length, objArrCopyOf.length);
        return new C1555j90(Arrays.copyOfRange(objArrCopyOf, 0, length));
    }

    @Override // java.util.List
    public final Object get(int i) {
        AbstractC2798wI.h(i, a());
        return this.l[i];
    }

    @Override // o.Y
    public final Y h(int i) {
        Object[] objArr = this.l;
        AbstractC2798wI.h(i, objArr.length);
        if (objArr.length == 1) {
            return m;
        }
        Object[] objArrCopyOf = Arrays.copyOf(objArr, objArr.length - 1);
        AbstractC2219q9.J(i, i + 1, objArr.length, objArr, objArrCopyOf);
        return new C1555j90(objArrCopyOf);
    }

    @Override // o.Y
    public final Y i(int i, Object obj) {
        AbstractC2798wI.h(i, a());
        Object[] objArr = this.l;
        Object[] objArrCopyOf = Arrays.copyOf(objArr, objArr.length);
        objArrCopyOf[i] = obj;
        return new C1555j90(objArrCopyOf);
    }

    @Override // o.Q, java.util.List
    public final int indexOf(Object obj) {
        return AbstractC2219q9.R(this.l, obj);
    }

    @Override // o.Q, java.util.List
    public final int lastIndexOf(Object obj) {
        Object[] objArr = this.l;
        if (obj == null) {
            int length = objArr.length - 1;
            if (length >= 0) {
                while (true) {
                    int i = length - 1;
                    if (objArr[length] == null) {
                        return length;
                    }
                    if (i < 0) {
                        break;
                    }
                    length = i;
                }
            }
        } else {
            int length2 = objArr.length - 1;
            if (length2 >= 0) {
                while (true) {
                    int i2 = length2 - 1;
                    if (obj.equals(objArr[length2])) {
                        return length2;
                    }
                    if (i2 < 0) {
                        break;
                    }
                    length2 = i2;
                }
            }
        }
        return -1;
    }

    @Override // o.Q, java.util.List
    public final ListIterator listIterator(int i) {
        Object[] objArr = this.l;
        AbstractC2798wI.i(i, objArr.length);
        return new C0828bf(objArr, i, objArr.length);
    }
}
