package com.google.android.gms.internal.pal;

import java.nio.charset.Charset;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* JADX INFO: loaded from: classes2.dex */
public final class f0 extends j implements RandomAccess, i0, f1 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final f0 f20793d;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int[] f20794b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f20795c;

    static {
        f0 f0Var = new f0(new int[0], 0);
        f20793d = f0Var;
        f0Var.f20990a = false;
    }

    public f0(int[] iArr, int i10) {
        this.f20794b = iArr;
        this.f20795c = i10;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i10, Object obj) {
        int i11;
        int iIntValue = ((Integer) obj).intValue();
        zza();
        if (i10 < 0 || i10 > (i11 = this.f20795c)) {
            throw new IndexOutOfBoundsException(defpackage.e.f("Index:", i10, ", Size:", this.f20795c));
        }
        int[] iArr = this.f20794b;
        if (i11 < iArr.length) {
            System.arraycopy(iArr, i10, iArr, i10 + 1, i11 - i10);
        } else {
            int[] iArr2 = new int[defpackage.e.C(i11, 3, 2, 1)];
            System.arraycopy(iArr, 0, iArr2, 0, i10);
            System.arraycopy(this.f20794b, i10, iArr2, i10 + 1, this.f20795c - i10);
            this.f20794b = iArr2;
        }
        this.f20794b[i10] = iIntValue;
        this.f20795c++;
        ((AbstractList) this).modCount++;
    }

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        zza();
        Charset charset = k0.f21003a;
        collection.getClass();
        if (!(collection instanceof f0)) {
            return super.addAll(collection);
        }
        f0 f0Var = (f0) collection;
        int i10 = f0Var.f20795c;
        if (i10 == 0) {
            return false;
        }
        int i11 = this.f20795c;
        if (Integer.MAX_VALUE - i11 < i10) {
            throw new OutOfMemoryError();
        }
        int i12 = i11 + i10;
        int[] iArr = this.f20794b;
        if (i12 > iArr.length) {
            this.f20794b = Arrays.copyOf(iArr, i12);
        }
        System.arraycopy(f0Var.f20794b, 0, this.f20794b, this.f20795c, f0Var.f20795c);
        this.f20795c = i12;
        ((AbstractList) this).modCount++;
        return true;
    }

    public final void c(int i10) {
        zza();
        int i11 = this.f20795c;
        int[] iArr = this.f20794b;
        if (i11 == iArr.length) {
            int[] iArr2 = new int[defpackage.e.C(i11, 3, 2, 1)];
            System.arraycopy(iArr, 0, iArr2, 0, i11);
            this.f20794b = iArr2;
        }
        int[] iArr3 = this.f20794b;
        int i12 = this.f20795c;
        this.f20795c = i12 + 1;
        iArr3[i12] = i10;
    }

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

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof f0)) {
            return super.equals(obj);
        }
        f0 f0Var = (f0) obj;
        if (this.f20795c != f0Var.f20795c) {
            return false;
        }
        int[] iArr = f0Var.f20794b;
        for (int i10 = 0; i10 < this.f20795c; i10++) {
            if (this.f20794b[i10] != iArr[i10]) {
                return false;
            }
        }
        return true;
    }

    public final void f(int i10) {
        if (i10 < 0 || i10 >= this.f20795c) {
            throw new IndexOutOfBoundsException(defpackage.e.f("Index:", i10, ", Size:", this.f20795c));
        }
    }

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

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int i10 = 1;
        for (int i11 = 0; i11 < this.f20795c; i11++) {
            i10 = (i10 * 31) + this.f20794b[i11];
        }
        return i10;
    }

    @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 i10 = this.f20795c;
        for (int i11 = 0; i11 < i10; i11++) {
            if (this.f20794b[i11] == iIntValue) {
                return i11;
            }
        }
        return -1;
    }

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object remove(int i10) {
        zza();
        f(i10);
        int[] iArr = this.f20794b;
        int i11 = iArr[i10];
        if (i10 < this.f20795c - 1) {
            System.arraycopy(iArr, i10 + 1, iArr, i10, (r2 - i10) - 1);
        }
        this.f20795c--;
        ((AbstractList) this).modCount++;
        return Integer.valueOf(i11);
    }

    @Override // java.util.AbstractList
    public final void removeRange(int i10, int i11) {
        zza();
        if (i11 < i10) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        int[] iArr = this.f20794b;
        System.arraycopy(iArr, i11, iArr, i10, this.f20795c - i11);
        this.f20795c -= i11 - i10;
        ((AbstractList) this).modCount++;
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object set(int i10, Object obj) {
        int iIntValue = ((Integer) obj).intValue();
        zza();
        f(i10);
        int[] iArr = this.f20794b;
        int i11 = iArr[i10];
        iArr[i10] = iIntValue;
        return Integer.valueOf(i11);
    }

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

    @Override // com.google.android.gms.internal.pal.j0
    public final /* bridge */ /* synthetic */ j0 zzd(int i10) {
        if (i10 >= this.f20795c) {
            return new f0(Arrays.copyOf(this.f20794b, i10), this.f20795c);
        }
        throw new IllegalArgumentException();
    }

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final /* bridge */ /* synthetic */ boolean add(Object obj) {
        c(((Integer) obj).intValue());
        return true;
    }
}
