package com.google.protobuf;

import java.nio.charset.Charset;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* JADX INFO: renamed from: com.google.protobuf.j0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C1313j0 extends AbstractC1300d implements X, RandomAccess, C0 {

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

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

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

    public C1313j0(long[] jArr, int i6, boolean z6) {
        super(z6);
        this.f14283b = jArr;
        this.f14284c = i6;
    }

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

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

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        e();
        Charset charset = Z.f14234a;
        collection.getClass();
        if (!(collection instanceof C1313j0)) {
            return super.addAll(collection);
        }
        C1313j0 c1313j0 = (C1313j0) collection;
        int i6 = c1313j0.f14284c;
        if (i6 == 0) {
            return false;
        }
        int i7 = this.f14284c;
        if (Integer.MAX_VALUE - i7 < i6) {
            throw new OutOfMemoryError();
        }
        int i8 = i7 + i6;
        long[] jArr = this.f14283b;
        if (i8 > jArr.length) {
            this.f14283b = Arrays.copyOf(jArr, i8);
        }
        System.arraycopy(c1313j0.f14283b, 0, this.f14283b, this.f14284c, c1313j0.f14284c);
        this.f14284c = i8;
        ((AbstractList) this).modCount++;
        return true;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean contains(Object obj) {
        return indexOf(obj) != -1;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C1313j0)) {
            return super.equals(obj);
        }
        C1313j0 c1313j0 = (C1313j0) obj;
        if (this.f14284c != c1313j0.f14284c) {
            return false;
        }
        long[] jArr = c1313j0.f14283b;
        for (int i6 = 0; i6 < this.f14284c; i6++) {
            if (this.f14283b[i6] != jArr[i6]) {
                return false;
            }
        }
        return true;
    }

    public final void g(long j4) {
        e();
        int i6 = this.f14284c;
        long[] jArr = this.f14283b;
        if (i6 == jArr.length) {
            long[] jArr2 = new long[Z0.o.A(i6, 3, 2, 1)];
            System.arraycopy(jArr, 0, jArr2, 0, i6);
            this.f14283b = jArr2;
        }
        long[] jArr3 = this.f14283b;
        int i7 = this.f14284c;
        this.f14284c = i7 + 1;
        jArr3[i7] = j4;
    }

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

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

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int iB = 1;
        for (int i6 = 0; i6 < this.f14284c; i6++) {
            iB = (iB * 31) + Z.b(this.f14283b[i6]);
        }
        return iB;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int indexOf(Object obj) {
        if (!(obj instanceof Long)) {
            return -1;
        }
        long jLongValue = ((Long) obj).longValue();
        int i6 = this.f14284c;
        for (int i7 = 0; i7 < i6; i7++) {
            if (this.f14283b[i7] == jLongValue) {
                return i7;
            }
        }
        return -1;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        h(i6);
        long[] jArr = this.f14283b;
        long j4 = jArr[i6];
        if (i6 < this.f14284c - 1) {
            System.arraycopy(jArr, i6 + 1, jArr, i6, (r3 - i6) - 1);
        }
        this.f14284c--;
        ((AbstractList) this).modCount++;
        return Long.valueOf(j4);
    }

    @Override // java.util.AbstractList
    public final void removeRange(int i6, int i7) {
        e();
        if (i7 < i6) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        long[] jArr = this.f14283b;
        System.arraycopy(jArr, i7, jArr, i6, this.f14284c - i7);
        this.f14284c -= i7 - i6;
        ((AbstractList) this).modCount++;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i6, Object obj) {
        long jLongValue = ((Long) obj).longValue();
        e();
        h(i6);
        long[] jArr = this.f14283b;
        long j4 = jArr[i6];
        jArr[i6] = jLongValue;
        return Long.valueOf(j4);
    }

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

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        g(((Long) obj).longValue());
        return true;
    }
}
