package o;

import com.google.android.gms.common.api.Api;
import java.nio.charset.Charset;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.wt0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2855wt0 extends Ps0 implements RandomAccess, Bt0, InterfaceC1049du0 {

    /* renamed from: o, reason: collision with root package name */
    public static final int[] f781o;
    public static final C2855wt0 p;
    public int[] m;
    public int n;

    static {
        int[] iArr = new int[0];
        f781o = iArr;
        p = new C2855wt0(iArr, 0, false);
    }

    public C2855wt0(int[] iArr, int i, boolean z) {
        super(z);
        this.m = iArr;
        this.n = i;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i, Object obj) {
        int i2;
        int iIntValue = ((Integer) obj).intValue();
        a();
        if (i < 0 || i > (i2 = this.n)) {
            throw new IndexOutOfBoundsException(Rs0.a(this.n, i, (byte) 13, "Index:", ", Size:"));
        }
        int i3 = i + 1;
        int[] iArr = this.m;
        int length = iArr.length;
        if (i2 < length) {
            System.arraycopy(iArr, i, iArr, i3, i2 - i);
        } else {
            int[] iArr2 = new int[Math.max(((length * 3) / 2) + 1, 10)];
            System.arraycopy(this.m, 0, iArr2, 0, i);
            System.arraycopy(this.m, i, iArr2, i3, this.n - i);
            this.m = iArr2;
        }
        this.m[i] = iIntValue;
        this.n++;
        ((AbstractList) this).modCount++;
    }

    @Override // o.Ps0, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        a();
        Charset charset = Et0.a;
        collection.getClass();
        if (!(collection instanceof C2855wt0)) {
            return super.addAll(collection);
        }
        C2855wt0 c2855wt0 = (C2855wt0) collection;
        int i = c2855wt0.n;
        if (i == 0) {
            return false;
        }
        int i2 = this.n;
        if (Api.BaseClientBuilder.API_PRIORITY_OTHER - i2 < i) {
            throw new OutOfMemoryError();
        }
        int i3 = i2 + i;
        int[] iArr = this.m;
        if (i3 > iArr.length) {
            this.m = Arrays.copyOf(iArr, i3);
        }
        System.arraycopy(c2855wt0.m, 0, this.m, this.n, c2855wt0.n);
        this.n = i3;
        ((AbstractList) this).modCount++;
        return true;
    }

    @Override // o.Dt0
    /* renamed from: b, reason: merged with bridge method [inline-methods] */
    public final C2855wt0 g(int i) {
        if (i >= this.n) {
            return new C2855wt0(i == 0 ? f781o : Arrays.copyOf(this.m, i), this.n, true);
        }
        throw new IllegalArgumentException();
    }

    public final int c(int i) {
        e(i);
        return this.m[i];
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean contains(Object obj) {
        return indexOf(obj) != -1;
    }

    public final void d(int i) {
        a();
        int i2 = this.n;
        int length = this.m.length;
        if (i2 == length) {
            int[] iArr = new int[Math.max(((length * 3) / 2) + 1, 10)];
            System.arraycopy(this.m, 0, iArr, 0, this.n);
            this.m = iArr;
        }
        int[] iArr2 = this.m;
        int i3 = this.n;
        this.n = i3 + 1;
        iArr2[i3] = i;
    }

    public final void e(int i) {
        if (i < 0 || i >= this.n) {
            throw new IndexOutOfBoundsException(Rs0.a(this.n, i, (byte) 13, "Index:", ", Size:"));
        }
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C2855wt0)) {
            return super.equals(obj);
        }
        C2855wt0 c2855wt0 = (C2855wt0) obj;
        if (this.n != c2855wt0.n) {
            return false;
        }
        int[] iArr = c2855wt0.m;
        for (int i = 0; i < this.n; i++) {
            if (this.m[i] != iArr[i]) {
                return false;
            }
        }
        return true;
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* synthetic */ Object get(int i) {
        e(i);
        return Integer.valueOf(this.m[i]);
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int i = 1;
        for (int i2 = 0; i2 < this.n; i2++) {
            i = (i * 31) + this.m[i2];
        }
        return i;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int indexOf(Object obj) {
        if (!(obj instanceof Integer)) {
            return -1;
        }
        int iIntValue = ((Integer) obj).intValue();
        int i = this.n;
        for (int i2 = 0; i2 < i; i2++) {
            if (this.m[i2] == iIntValue) {
                return i2;
            }
        }
        return -1;
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object remove(int i) {
        a();
        e(i);
        int[] iArr = this.m;
        int i2 = iArr[i];
        if (i < this.n - 1) {
            System.arraycopy(iArr, i + 1, iArr, i, (r2 - i) - 1);
        }
        this.n--;
        ((AbstractList) this).modCount++;
        return Integer.valueOf(i2);
    }

    @Override // java.util.AbstractList
    public final void removeRange(int i, int i2) {
        a();
        if (i2 < i) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        int[] iArr = this.m;
        System.arraycopy(iArr, i2, iArr, i, this.n - i2);
        this.n -= i2 - i;
        ((AbstractList) this).modCount++;
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object set(int i, Object obj) {
        int iIntValue = ((Integer) obj).intValue();
        a();
        e(i);
        int[] iArr = this.m;
        int i2 = iArr[i];
        iArr[i] = iIntValue;
        return Integer.valueOf(i2);
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final int size() {
        return this.n;
    }

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final /* bridge */ /* synthetic */ boolean add(Object obj) {
        d(((Integer) obj).intValue());
        return true;
    }
}
