package o;

import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class GL extends V implements RandomAccess, Serializable {
    public Object[] l;
    public final int m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public final GL f134o;
    public final HL p;

    public GL(Object[] objArr, int i, int i2, GL gl, HL hl) {
        this.l = objArr;
        this.m = i;
        this.n = i2;
        this.f134o = gl;
        this.p = hl;
        ((AbstractList) this).modCount = ((AbstractList) hl).modCount;
    }

    private final Object writeReplace() throws NotSerializableException {
        if (this.p.n) {
            return new P60(this, 0);
        }
        throw new NotSerializableException("The list cannot be serialized while it is being built.");
    }

    @Override // o.V
    public final int a() {
        f();
        return this.n;
    }

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        h();
        f();
        e(this.m + this.n, obj);
        return true;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        h();
        f();
        int size = collection.size();
        d(this.m + this.n, collection, size);
        return size > 0;
    }

    @Override // o.V
    public final Object b(int i) {
        h();
        f();
        int i2 = this.n;
        if (i < 0 || i >= i2) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
        }
        return i(this.m + i);
    }

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final void clear() {
        h();
        f();
        k(this.m, this.n);
    }

    public final void d(int i, Collection collection, int i2) {
        ((AbstractList) this).modCount++;
        HL hl = this.p;
        GL gl = this.f134o;
        if (gl != null) {
            gl.d(i, collection, i2);
        } else {
            HL hl2 = HL.f144o;
            hl.d(i, collection, i2);
        }
        this.l = hl.l;
        this.n += i2;
    }

    public final void e(int i, Object obj) {
        ((AbstractList) this).modCount++;
        HL hl = this.p;
        GL gl = this.f134o;
        if (gl != null) {
            gl.e(i, obj);
        } else {
            HL hl2 = HL.f144o;
            hl.e(i, obj);
        }
        this.l = hl.l;
        this.n++;
    }

    @Override // java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        f();
        if (obj == this) {
            return true;
        }
        if (obj instanceof List) {
            List list = (List) obj;
            Object[] objArr = this.l;
            int i = this.n;
            if (i == list.size()) {
                for (int i2 = 0; i2 < i; i2++) {
                    if (F3.c(objArr[this.m + i2], list.get(i2))) {
                    }
                }
                return true;
            }
        }
        return false;
    }

    public final void f() {
        if (((AbstractList) this.p).modCount != ((AbstractList) this).modCount) {
            throw new ConcurrentModificationException();
        }
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object get(int i) {
        f();
        int i2 = this.n;
        if (i < 0 || i >= i2) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
        }
        return this.l[this.m + i];
    }

    public final void h() {
        if (this.p.n) {
            throw new UnsupportedOperationException();
        }
    }

    @Override // java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        f();
        Object[] objArr = this.l;
        int i = this.n;
        int iHashCode = 1;
        for (int i2 = 0; i2 < i; i2++) {
            Object obj = objArr[this.m + i2];
            iHashCode = (iHashCode * 31) + (obj != null ? obj.hashCode() : 0);
        }
        return iHashCode;
    }

    public final Object i(int i) {
        Object objI;
        ((AbstractList) this).modCount++;
        GL gl = this.f134o;
        if (gl != null) {
            objI = gl.i(i);
        } else {
            HL hl = HL.f144o;
            objI = this.p.i(i);
        }
        this.n--;
        return objI;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int indexOf(Object obj) {
        f();
        for (int i = 0; i < this.n; i++) {
            if (F3.c(this.l[this.m + i], obj)) {
                return i;
            }
        }
        return -1;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean isEmpty() {
        f();
        return this.n == 0;
    }

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.List
    public final Iterator iterator() {
        return listIterator(0);
    }

    public final void k(int i, int i2) {
        if (i2 > 0) {
            ((AbstractList) this).modCount++;
        }
        GL gl = this.f134o;
        if (gl != null) {
            gl.k(i, i2);
        } else {
            HL hl = HL.f144o;
            this.p.k(i, i2);
        }
        this.n -= i2;
    }

    public final int l(int i, int i2, Collection collection, boolean z) {
        int iL;
        GL gl = this.f134o;
        if (gl != null) {
            iL = gl.l(i, i2, collection, z);
        } else {
            HL hl = HL.f144o;
            iL = this.p.l(i, i2, collection, z);
        }
        if (iL > 0) {
            ((AbstractList) this).modCount++;
        }
        this.n -= iL;
        return iL;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int lastIndexOf(Object obj) {
        f();
        for (int i = this.n - 1; i >= 0; i--) {
            if (F3.c(this.l[this.m + i], obj)) {
                return i;
            }
        }
        return -1;
    }

    @Override // java.util.AbstractList, java.util.List
    public final ListIterator listIterator() {
        return listIterator(0);
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean remove(Object obj) {
        h();
        f();
        int iIndexOf = indexOf(obj);
        if (iIndexOf >= 0) {
            b(iIndexOf);
        }
        return iIndexOf >= 0;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean removeAll(Collection collection) {
        h();
        f();
        return l(this.m, this.n, collection, false) > 0;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean retainAll(Collection collection) {
        h();
        f();
        return l(this.m, this.n, collection, true) > 0;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i, Object obj) {
        h();
        f();
        int i2 = this.n;
        if (i < 0 || i >= i2) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
        }
        Object[] objArr = this.l;
        int i3 = this.m;
        Object obj2 = objArr[i3 + i];
        objArr[i3 + i] = obj;
        return obj2;
    }

    @Override // java.util.AbstractList, java.util.List
    public final List subList(int i, int i2) {
        AbstractC0752ap.x(i, i2, this.n);
        return new GL(this.l, this.m + i, i2 - i, this, this.p);
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final Object[] toArray(Object[] objArr) {
        f();
        int length = objArr.length;
        int i = this.n;
        int i2 = this.m;
        if (length < i) {
            return Arrays.copyOfRange(this.l, i2, i + i2, objArr.getClass());
        }
        AbstractC2219q9.J(0, i2, i + i2, this.l, objArr);
        int i3 = this.n;
        if (i3 < objArr.length) {
            objArr[i3] = null;
        }
        return objArr;
    }

    @Override // java.util.AbstractCollection
    public final String toString() {
        f();
        return AbstractC0249Jp.m(this.l, this.m, this.n, this);
    }

    @Override // java.util.AbstractList, java.util.List
    public final ListIterator listIterator(int i) {
        f();
        int i2 = this.n;
        if (i < 0 || i > i2) {
            throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
        }
        return new C1083eF(this, i);
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i, Object obj) {
        h();
        f();
        int i2 = this.n;
        if (i >= 0 && i <= i2) {
            e(this.m + i, obj);
            return;
        }
        throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
    }

    @Override // java.util.AbstractList, java.util.List
    public final boolean addAll(int i, Collection collection) {
        h();
        f();
        int i2 = this.n;
        if (i >= 0 && i <= i2) {
            int size = collection.size();
            d(this.m + i, collection, size);
            return size > 0;
        }
        throw new IndexOutOfBoundsException(AbstractC0126Ew.i(i, i2, "index: ", ", size: "));
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final Object[] toArray() {
        f();
        Object[] objArr = this.l;
        int i = this.n;
        int i2 = this.m;
        int i3 = i + i2;
        AbstractC2461sm0.d(i3, objArr.length);
        return Arrays.copyOfRange(objArr, i2, i3);
    }
}
