package com.google.crypto.tink.shaded.protobuf;

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

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

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

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

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

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

    static {
        Object[] objArr = new Object[0];
        f23986d = objArr;
        f23987e = new x0(objArr, 0, false);
    }

    public x0(Object[] objArr, int i10, boolean z10) {
        super(z10);
        this.f23988b = objArr;
        this.f23989c = i10;
    }

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

    @Override // com.google.crypto.tink.shaded.protobuf.a0
    public final a0 d(int i10) {
        if (i10 >= this.f23989c) {
            return new x0(i10 == 0 ? f23986d : Arrays.copyOf(this.f23988b, i10), this.f23989c, true);
        }
        throw new IllegalArgumentException();
    }

    public final void g(int i10) {
        if (i10 < 0 || i10 >= this.f23989c) {
            StringBuilder sbQ = defpackage.e.q("Index:", i10, ", Size:");
            sbQ.append(this.f23989c);
            throw new IndexOutOfBoundsException(sbQ.toString());
        }
    }

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

    @Override // com.google.crypto.tink.shaded.protobuf.c, java.util.AbstractList, java.util.List
    public final Object remove(int i10) {
        c();
        g(i10);
        Object[] objArr = this.f23988b;
        Object obj = objArr[i10];
        if (i10 < this.f23989c - 1) {
            System.arraycopy(objArr, i10 + 1, objArr, i10, (r2 - i10) - 1);
        }
        this.f23989c--;
        ((AbstractList) this).modCount++;
        return obj;
    }

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

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i10, Object obj) {
        int i11;
        c();
        if (i10 >= 0 && i10 <= (i11 = this.f23989c)) {
            Object[] objArr = this.f23988b;
            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.f23988b, 0, objArr2, 0, i10);
                System.arraycopy(this.f23988b, i10, objArr2, i10 + 1, this.f23989c - i10);
                this.f23988b = objArr2;
            }
            this.f23988b[i10] = obj;
            this.f23989c++;
            ((AbstractList) this).modCount++;
            return;
        }
        StringBuilder sbQ = defpackage.e.q("Index:", i10, ", Size:");
        sbQ.append(this.f23989c);
        throw new IndexOutOfBoundsException(sbQ.toString());
    }
}
