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

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 db2 extends da2 implements RandomAccess, gb2, cc2 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final int[] f10366d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final db2 f10367e;

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

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

    static {
        int[] iArr = new int[0];
        f10366d = iArr;
        f10367e = new db2(iArr, 0, false);
    }

    public db2(int[] iArr, int i10, boolean z10) {
        super(z10);
        this.f10368b = iArr;
        this.f10369c = i10;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i10, Object obj) {
        int i11;
        int iIntValue = ((Integer) obj).intValue();
        f();
        if (i10 < 0 || i10 > (i11 = this.f10369c)) {
            throw new IndexOutOfBoundsException(l(i10));
        }
        int i12 = i10 + 1;
        int[] iArr = this.f10368b;
        int length = iArr.length;
        if (i11 < length) {
            System.arraycopy(iArr, i10, iArr, i12, i11 - i10);
        } else {
            int[] iArr2 = new int[com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(length, 3, 2, 1, 10)];
            System.arraycopy(this.f10368b, 0, iArr2, 0, i10);
            System.arraycopy(this.f10368b, i10, iArr2, i12, this.f10369c - i10);
            this.f10368b = iArr2;
        }
        this.f10368b[i10] = iIntValue;
        this.f10369c++;
        ((AbstractList) this).modCount++;
    }

    @Override // com.google.android.gms.internal.ads.da2, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        f();
        Charset charset = kb2.f13211a;
        collection.getClass();
        if (!(collection instanceof db2)) {
            return super.addAll(collection);
        }
        db2 db2Var = (db2) collection;
        int i10 = db2Var.f10369c;
        if (i10 == 0) {
            return false;
        }
        int i11 = this.f10369c;
        if (Integer.MAX_VALUE - i11 < i10) {
            throw new OutOfMemoryError();
        }
        int i12 = i11 + i10;
        int[] iArr = this.f10368b;
        if (i12 > iArr.length) {
            this.f10368b = Arrays.copyOf(iArr, i12);
        }
        System.arraycopy(db2Var.f10368b, 0, this.f10368b, this.f10369c, db2Var.f10369c);
        this.f10369c = i12;
        ((AbstractList) this).modCount++;
        return true;
    }

    @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.ads.da2, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof db2)) {
            return super.equals(obj);
        }
        db2 db2Var = (db2) obj;
        if (this.f10369c != db2Var.f10369c) {
            return false;
        }
        int[] iArr = db2Var.f10368b;
        for (int i10 = 0; i10 < this.f10369c; i10++) {
            if (this.f10368b[i10] != iArr[i10]) {
                return false;
            }
        }
        return true;
    }

    @Override // com.google.android.gms.internal.ads.jb2
    /* JADX INFO: renamed from: g, reason: merged with bridge method [inline-methods] */
    public final db2 zzh(int i10) {
        if (i10 >= this.f10369c) {
            return new db2(i10 == 0 ? f10366d : Arrays.copyOf(this.f10368b, i10), this.f10369c, true);
        }
        throw new IllegalArgumentException();
    }

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

    public final int h(int i10) {
        k(i10);
        return this.f10368b[i10];
    }

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

    public final void i(int i10) {
        f();
        int i11 = this.f10369c;
        int length = this.f10368b.length;
        if (i11 == length) {
            int[] iArr = new int[com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(length, 3, 2, 1, 10)];
            System.arraycopy(this.f10368b, 0, iArr, 0, this.f10369c);
            this.f10368b = iArr;
        }
        int[] iArr2 = this.f10368b;
        int i12 = this.f10369c;
        this.f10369c = i12 + 1;
        iArr2[i12] = 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.f10369c;
        for (int i11 = 0; i11 < i10; i11++) {
            if (this.f10368b[i11] == iIntValue) {
                return i11;
            }
        }
        return -1;
    }

    public final void j(int i10) {
        int length = this.f10368b.length;
        if (i10 <= length) {
            return;
        }
        if (length == 0) {
            this.f10368b = new int[Math.max(i10, 10)];
            return;
        }
        while (length < i10) {
            length = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(length, 3, 2, 1, 10);
        }
        this.f10368b = Arrays.copyOf(this.f10368b, length);
    }

    public final void k(int i10) {
        if (i10 < 0 || i10 >= this.f10369c) {
            throw new IndexOutOfBoundsException(l(i10));
        }
    }

    public final String l(int i10) {
        int i11 = this.f10369c;
        return com.google.android.gms.measurement.internal.u1.m(new StringBuilder(String.valueOf(i10).length() + 13 + String.valueOf(i11).length()), "Index:", i10, ", Size:", i11);
    }

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

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

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i10, Object obj) {
        int iIntValue = ((Integer) obj).intValue();
        f();
        k(i10);
        int[] iArr = this.f10368b;
        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.f10369c;
    }

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