package com.google.protobuf;

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

/* JADX INFO: loaded from: classes3.dex */
public final class E0 extends AbstractC1300d implements RandomAccess {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final E0 f14175d = new E0(new Object[0], 0, false);

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

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

    public E0(Object[] objArr, int i6, boolean z6) {
        super(z6);
        this.f14176b = objArr;
        this.f14177c = i6;
    }

    @Override // com.google.protobuf.Y
    public final Y a(int i6) {
        if (i6 >= this.f14177c) {
            return new E0(Arrays.copyOf(this.f14176b, i6), this.f14177c, true);
        }
        throw new IllegalArgumentException();
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        e();
        int i6 = this.f14177c;
        Object[] objArr = this.f14176b;
        if (i6 == objArr.length) {
            this.f14176b = Arrays.copyOf(objArr, ((i6 * 3) / 2) + 1);
        }
        Object[] objArr2 = this.f14176b;
        int i7 = this.f14177c;
        this.f14177c = i7 + 1;
        objArr2[i7] = obj;
        ((AbstractList) this).modCount++;
        return true;
    }

    public final void g(int i6) {
        if (i6 < 0 || i6 >= this.f14177c) {
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
            sbR.append(this.f14177c);
            throw new IndexOutOfBoundsException(sbR.toString());
        }
    }

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

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        g(i6);
        Object[] objArr = this.f14176b;
        Object obj = objArr[i6];
        if (i6 < this.f14177c - 1) {
            System.arraycopy(objArr, i6 + 1, objArr, i6, (r2 - i6) - 1);
        }
        this.f14177c--;
        ((AbstractList) this).modCount++;
        return obj;
    }

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

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

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i6, Object obj) {
        int i7;
        e();
        if (i6 >= 0 && i6 <= (i7 = this.f14177c)) {
            Object[] objArr = this.f14176b;
            if (i7 < objArr.length) {
                System.arraycopy(objArr, i6, objArr, i6 + 1, i7 - i6);
            } else {
                Object[] objArr2 = new Object[Z0.o.A(i7, 3, 2, 1)];
                System.arraycopy(objArr, 0, objArr2, 0, i6);
                System.arraycopy(this.f14176b, i6, objArr2, i6 + 1, this.f14177c - i6);
                this.f14176b = objArr2;
            }
            this.f14176b[i6] = obj;
            this.f14177c++;
            ((AbstractList) this).modCount++;
            return;
        }
        StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
        sbR.append(this.f14177c);
        throw new IndexOutOfBoundsException(sbR.toString());
    }
}
