package com.google.protobuf;

import com.google.android.gms.common.api.Api;
import com.google.protobuf.z;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class i0 extends c implements z.i, RandomAccess, b1 {

    /* renamed from: s, reason: collision with root package name */
    private static final i0 f15079s = new i0(new long[0], 0, false);

    /* renamed from: q, reason: collision with root package name */
    private long[] f15080q;

    /* renamed from: r, reason: collision with root package name */
    private int f15081r;

    private i0(long[] jArr, int i10, boolean z10) {
        super(z10);
        this.f15080q = jArr;
        this.f15081r = i10;
    }

    private void k(int i10, long j10) {
        int i11;
        e();
        if (i10 < 0 || i10 > (i11 = this.f15081r)) {
            throw new IndexOutOfBoundsException(r(i10));
        }
        long[] jArr = this.f15080q;
        if (i11 < jArr.length) {
            System.arraycopy(jArr, i10, jArr, i10 + 1, i11 - i10);
        } else {
            long[] jArr2 = new long[((i11 * 3) / 2) + 1];
            System.arraycopy(jArr, 0, jArr2, 0, i10);
            System.arraycopy(this.f15080q, i10, jArr2, i10 + 1, this.f15081r - i10);
            this.f15080q = jArr2;
        }
        this.f15080q[i10] = j10;
        this.f15081r++;
        ((AbstractList) this).modCount++;
    }

    public static i0 m() {
        return f15079s;
    }

    private void n(int i10) {
        if (i10 < 0 || i10 >= this.f15081r) {
            throw new IndexOutOfBoundsException(r(i10));
        }
    }

    private String r(int i10) {
        return "Index:" + i10 + ", Size:" + this.f15081r;
    }

    @Override // com.google.protobuf.c, java.util.AbstractCollection, java.util.Collection, java.util.List
    public boolean addAll(Collection collection) {
        e();
        z.a(collection);
        if (!(collection instanceof i0)) {
            return super.addAll(collection);
        }
        i0 i0Var = (i0) collection;
        int i10 = i0Var.f15081r;
        if (i10 == 0) {
            return false;
        }
        int i11 = this.f15081r;
        if (Api.BaseClientBuilder.API_PRIORITY_OTHER - i11 < i10) {
            throw new OutOfMemoryError();
        }
        int i12 = i11 + i10;
        long[] jArr = this.f15080q;
        if (i12 > jArr.length) {
            this.f15080q = Arrays.copyOf(jArr, i12);
        }
        System.arraycopy(i0Var.f15080q, 0, this.f15080q, this.f15081r, i0Var.f15081r);
        this.f15081r = i12;
        ((AbstractList) this).modCount++;
        return true;
    }

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

    @Override // com.google.protobuf.c, java.util.AbstractList, java.util.Collection, java.util.List
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof i0)) {
            return super.equals(obj);
        }
        i0 i0Var = (i0) obj;
        if (this.f15081r != i0Var.f15081r) {
            return false;
        }
        long[] jArr = i0Var.f15080q;
        for (int i10 = 0; i10 < this.f15081r; i10++) {
            if (this.f15080q[i10] != jArr[i10]) {
                return false;
            }
        }
        return true;
    }

    @Override // java.util.AbstractList, java.util.List
    /* renamed from: g, reason: merged with bridge method [inline-methods] */
    public void add(int i10, Long l10) {
        k(i10, l10.longValue());
    }

    @Override // com.google.protobuf.c, java.util.AbstractList, java.util.Collection, java.util.List
    public int hashCode() {
        int i10 = 1;
        for (int i11 = 0; i11 < this.f15081r; i11++) {
            i10 = (i10 * 31) + z.f(this.f15080q[i11]);
        }
        return i10;
    }

    @Override // com.google.protobuf.c, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    /* renamed from: i, reason: merged with bridge method [inline-methods] */
    public boolean add(Long l10) {
        l(l10.longValue());
        return true;
    }

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

    public void l(long j10) {
        e();
        int i10 = this.f15081r;
        long[] jArr = this.f15080q;
        if (i10 == jArr.length) {
            long[] jArr2 = new long[((i10 * 3) / 2) + 1];
            System.arraycopy(jArr, 0, jArr2, 0, i10);
            this.f15080q = jArr2;
        }
        long[] jArr3 = this.f15080q;
        int i11 = this.f15081r;
        this.f15081r = i11 + 1;
        jArr3[i11] = j10;
    }

    @Override // java.util.AbstractList, java.util.List
    /* renamed from: o, reason: merged with bridge method [inline-methods] */
    public Long get(int i10) {
        return Long.valueOf(q(i10));
    }

    public long q(int i10) {
        n(i10);
        return this.f15080q[i10];
    }

    @Override // java.util.AbstractList
    protected void removeRange(int i10, int i11) {
        e();
        if (i11 < i10) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        long[] jArr = this.f15080q;
        System.arraycopy(jArr, i11, jArr, i10, this.f15081r - i11);
        this.f15081r -= i11 - i10;
        ((AbstractList) this).modCount++;
    }

    @Override // com.google.protobuf.c, java.util.AbstractList, java.util.List
    /* renamed from: s, reason: merged with bridge method [inline-methods] */
    public Long remove(int i10) {
        e();
        n(i10);
        long[] jArr = this.f15080q;
        long j10 = jArr[i10];
        if (i10 < this.f15081r - 1) {
            System.arraycopy(jArr, i10 + 1, jArr, i10, (r3 - i10) - 1);
        }
        this.f15081r--;
        ((AbstractList) this).modCount++;
        return Long.valueOf(j10);
    }

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

    @Override // java.util.AbstractList, java.util.List
    /* renamed from: u, reason: merged with bridge method [inline-methods] */
    public Long set(int i10, Long l10) {
        return Long.valueOf(v(i10, l10.longValue()));
    }

    public long v(int i10, long j10) {
        e();
        n(i10);
        long[] jArr = this.f15080q;
        long j11 = jArr[i10];
        jArr[i10] = j10;
        return j11;
    }

    @Override // com.google.protobuf.z.j
    public z.i a(int i10) {
        if (i10 >= this.f15081r) {
            return new i0(Arrays.copyOf(this.f15080q, i10), this.f15081r, true);
        }
        throw new IllegalArgumentException();
    }
}
