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

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

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

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

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

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

    static {
        h1 h1Var = new h1(new Object[0], 0);
        f20941d = h1Var;
        h1Var.f20990a = false;
    }

    public h1(Object[] objArr, int i10) {
        this.f20942b = objArr;
        this.f20943c = 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.f20943c)) {
            throw new IndexOutOfBoundsException(defpackage.e.f("Index:", i10, ", Size:", this.f20943c));
        }
        Object[] objArr = this.f20942b;
        if (i11 < objArr.length) {
            System.arraycopy(objArr, i10, objArr, i10 + 1, i11 - i10);
        } else {
            Object[] objArr2 = new Object[defpackage.e.C(i11, 3, 2, 1)];
            System.arraycopy(objArr, 0, objArr2, 0, i10);
            System.arraycopy(this.f20942b, i10, objArr2, i10 + 1, this.f20943c - i10);
            this.f20942b = objArr2;
        }
        this.f20942b[i10] = obj;
        this.f20943c++;
        ((AbstractList) this).modCount++;
    }

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

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

    @Override // com.google.android.gms.internal.pal.j, java.util.AbstractList, java.util.List
    public final Object remove(int i10) {
        zza();
        c(i10);
        Object[] objArr = this.f20942b;
        Object obj = objArr[i10];
        if (i10 < this.f20943c - 1) {
            System.arraycopy(objArr, i10 + 1, objArr, i10, (r2 - i10) - 1);
        }
        this.f20943c--;
        ((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.f20942b;
        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.f20943c;
    }

    @Override // com.google.android.gms.internal.pal.j0
    public final /* bridge */ /* synthetic */ j0 zzd(int i10) {
        if (i10 >= this.f20943c) {
            return new h1(Arrays.copyOf(this.f20942b, i10), this.f20943c);
        }
        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 boolean add(Object obj) {
        zza();
        int i10 = this.f20943c;
        Object[] objArr = this.f20942b;
        if (i10 == objArr.length) {
            this.f20942b = Arrays.copyOf(objArr, ((i10 * 3) / 2) + 1);
        }
        Object[] objArr2 = this.f20942b;
        int i11 = this.f20943c;
        this.f20943c = i11 + 1;
        objArr2[i11] = obj;
        ((AbstractList) this).modCount++;
        return true;
    }
}
