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

import java.util.AbstractList;
import java.util.Arrays;
import java.util.RandomAccess;

/* JADX INFO: loaded from: classes2.dex */
public final class ec2 extends da2 implements RandomAccess {

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

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

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

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

    static {
        Object[] objArr = new Object[0];
        f10755d = objArr;
        f10756e = new ec2(objArr, 0, false);
    }

    public ec2(Object[] objArr, int i10, boolean z10) {
        super(z10);
        this.f10757b = objArr;
        this.f10758c = i10;
    }

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

    public final void g(int i10) {
        if (i10 < 0 || i10 >= this.f10758c) {
            throw new IndexOutOfBoundsException(h(i10));
        }
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object get(int i10) {
        g(i10);
        return this.f10757b[i10];
    }

    public final String h(int i10) {
        int i11 = this.f10758c;
        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 Object remove(int i10) {
        f();
        g(i10);
        Object[] objArr = this.f10757b;
        Object obj = objArr[i10];
        if (i10 < this.f10758c - 1) {
            System.arraycopy(objArr, i10 + 1, objArr, i10, (r2 - i10) - 1);
        }
        this.f10758c--;
        ((AbstractList) this).modCount++;
        return obj;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i10, Object obj) {
        f();
        g(i10);
        Object[] objArr = this.f10757b;
        Object obj2 = objArr[i10];
        objArr[i10] = obj;
        ((AbstractList) this).modCount++;
        return obj2;
    }

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

    @Override // com.google.android.gms.internal.ads.jb2
    public final /* bridge */ /* synthetic */ jb2 zzh(int i10) {
        if (i10 >= this.f10758c) {
            return new ec2(i10 == 0 ? f10755d : Arrays.copyOf(this.f10757b, i10), this.f10758c, true);
        }
        throw new IllegalArgumentException();
    }

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        f();
        int i10 = this.f10758c;
        int length = this.f10757b.length;
        if (i10 == length) {
            this.f10757b = Arrays.copyOf(this.f10757b, com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(length, 3, 2, 1, 10));
        }
        Object[] objArr = this.f10757b;
        int i11 = this.f10758c;
        this.f10758c = i11 + 1;
        objArr[i11] = obj;
        ((AbstractList) this).modCount++;
        return true;
    }
}
