package androidx.datastore.preferences.protobuf;

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

/* JADX INFO: loaded from: classes.dex */
public final class V extends AbstractC1013b implements RandomAccess {

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

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

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

    static {
        V v3 = new V(new Object[0], 0);
        f11343d = v3;
        v3.f11361a = false;
    }

    public V(Object[] objArr, int i6) {
        this.f11344b = objArr;
        this.f11345c = i6;
    }

    @Override // androidx.datastore.preferences.protobuf.InterfaceC1031u
    public final InterfaceC1031u a(int i6) {
        if (i6 >= this.f11345c) {
            return new V(Arrays.copyOf(this.f11344b, i6), this.f11345c);
        }
        throw new IllegalArgumentException();
    }

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

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

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

    @Override // androidx.datastore.preferences.protobuf.AbstractC1013b, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        g(i6);
        Object[] objArr = this.f11344b;
        Object obj = objArr[i6];
        if (i6 < this.f11345c - 1) {
            System.arraycopy(objArr, i6 + 1, objArr, i6, (r2 - i6) - 1);
        }
        this.f11345c--;
        ((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.f11344b;
        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.f11345c;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i6, Object obj) {
        int i7;
        e();
        if (i6 >= 0 && i6 <= (i7 = this.f11345c)) {
            Object[] objArr = this.f11344b;
            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.f11344b, i6, objArr2, i6 + 1, this.f11345c - i6);
                this.f11344b = objArr2;
            }
            this.f11344b[i6] = obj;
            this.f11345c++;
            ((AbstractList) this).modCount++;
            return;
        }
        StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
        sbR.append(this.f11345c);
        throw new IndexOutOfBoundsException(sbR.toString());
    }
}
