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

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

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

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

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

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

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

    static {
        Object[] objArr = new Object[0];
        f20100d = objArr;
        f20101e = new a7(objArr, 0, false);
    }

    public a7(Object[] objArr, int i10, boolean z10) {
        super(z10);
        this.f20102b = objArr;
        this.f20103c = i10;
    }

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

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

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

    @Override // com.google.android.gms.internal.measurement.o5, java.util.AbstractList, java.util.List
    public final Object remove(int i10) {
        zza();
        c(i10);
        Object[] objArr = this.f20102b;
        Object obj = objArr[i10];
        if (i10 < this.f20103c - 1) {
            System.arraycopy(objArr, i10 + 1, objArr, i10, (r2 - i10) - 1);
        }
        this.f20103c--;
        ((AbstractList) this).modCount++;
        return obj;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i10, Object obj) {
        zza();
        c(i10);
        Object[] objArr = this.f20102b;
        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.f20103c;
    }

    @Override // com.google.android.gms.internal.measurement.k6
    public final /* synthetic */ k6 zza(int i10) {
        if (i10 >= this.f20103c) {
            return new a7(i10 == 0 ? f20100d : Arrays.copyOf(this.f20102b, i10), this.f20103c, true);
        }
        throw new IllegalArgumentException();
    }

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