package o;

import com.google.android.gms.common.api.Api;
import java.nio.charset.Charset;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Nt0 extends Ps0 implements RandomAccess, Ct0, InterfaceC1049du0 {

    /* renamed from: o, reason: collision with root package name */
    public static final long[] f260o;
    public static final Nt0 p;
    public long[] m;
    public int n;

    static {
        long[] jArr = new long[0];
        f260o = jArr;
        p = new Nt0(jArr, 0, false);
    }

    public Nt0(long[] jArr, int i, boolean z) {
        super(z);
        this.m = jArr;
        this.n = i;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i, Object obj) {
        int i2;
        long jLongValue = ((Long) obj).longValue();
        a();
        if (i < 0 || i > (i2 = this.n)) {
            throw new IndexOutOfBoundsException(Rs0.a(this.n, i, (byte) 13, "Index:", ", Size:"));
        }
        int i3 = i + 1;
        long[] jArr = this.m;
        int length = jArr.length;
        if (i2 < length) {
            System.arraycopy(jArr, i, jArr, i3, i2 - i);
        } else {
            long[] jArr2 = new long[Math.max(((length * 3) / 2) + 1, 10)];
            System.arraycopy(this.m, 0, jArr2, 0, i);
            System.arraycopy(this.m, i, jArr2, i3, this.n - i);
            this.m = jArr2;
        }
        this.m[i] = jLongValue;
        this.n++;
        ((AbstractList) this).modCount++;
    }

    @Override // o.Ps0, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        a();
        Charset charset = Et0.a;
        collection.getClass();
        if (!(collection instanceof Nt0)) {
            return super.addAll(collection);
        }
        Nt0 nt0 = (Nt0) collection;
        int i = nt0.n;
        if (i == 0) {
            return false;
        }
        int i2 = this.n;
        if (Api.BaseClientBuilder.API_PRIORITY_OTHER - i2 < i) {
            throw new OutOfMemoryError();
        }
        int i3 = i2 + i;
        long[] jArr = this.m;
        if (i3 > jArr.length) {
            this.m = Arrays.copyOf(jArr, i3);
        }
        System.arraycopy(nt0.m, 0, this.m, this.n, nt0.n);
        this.n = i3;
        ((AbstractList) this).modCount++;
        return true;
    }

    public final long b(int i) {
        e(i);
        return this.m[i];
    }

    @Override // o.Dt0
    /* renamed from: c, reason: merged with bridge method [inline-methods] */
    public final Nt0 g(int i) {
        if (i >= this.n) {
            return new Nt0(i == 0 ? f260o : Arrays.copyOf(this.m, i), this.n, true);
        }
        throw new IllegalArgumentException();
    }

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

    public final void d(long j) {
        a();
        int i = this.n;
        int length = this.m.length;
        if (i == length) {
            long[] jArr = new long[Math.max(((length * 3) / 2) + 1, 10)];
            System.arraycopy(this.m, 0, jArr, 0, this.n);
            this.m = jArr;
        }
        long[] jArr2 = this.m;
        int i2 = this.n;
        this.n = i2 + 1;
        jArr2[i2] = j;
    }

    public final void e(int i) {
        if (i < 0 || i >= this.n) {
            throw new IndexOutOfBoundsException(Rs0.a(this.n, i, (byte) 13, "Index:", ", Size:"));
        }
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Nt0)) {
            return super.equals(obj);
        }
        Nt0 nt0 = (Nt0) obj;
        if (this.n != nt0.n) {
            return false;
        }
        long[] jArr = nt0.m;
        for (int i = 0; i < this.n; i++) {
            if (this.m[i] != jArr[i]) {
                return false;
            }
        }
        return true;
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* synthetic */ Object get(int i) {
        e(i);
        return Long.valueOf(this.m[i]);
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int i = 1;
        for (int i2 = 0; i2 < this.n; i2++) {
            long j = this.m[i2];
            Charset charset = Et0.a;
            i = (i * 31) + ((int) (j ^ (j >>> 32)));
        }
        return i;
    }

    @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 i = this.n;
        for (int i2 = 0; i2 < i; i2++) {
            if (this.m[i2] == jLongValue) {
                return i2;
            }
        }
        return -1;
    }

    @Override // o.Ps0, java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object remove(int i) {
        a();
        e(i);
        long[] jArr = this.m;
        long j = jArr[i];
        if (i < this.n - 1) {
            System.arraycopy(jArr, i + 1, jArr, i, (r3 - i) - 1);
        }
        this.n--;
        ((AbstractList) this).modCount++;
        return Long.valueOf(j);
    }

    @Override // java.util.AbstractList
    public final void removeRange(int i, int i2) {
        a();
        if (i2 < i) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        long[] jArr = this.m;
        System.arraycopy(jArr, i2, jArr, i, this.n - i2);
        this.n -= i2 - i;
        ((AbstractList) this).modCount++;
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* bridge */ /* synthetic */ Object set(int i, Object obj) {
        long jLongValue = ((Long) obj).longValue();
        a();
        e(i);
        long[] jArr = this.m;
        long j = jArr[i];
        jArr[i] = jLongValue;
        return Long.valueOf(j);
    }

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

    @Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final /* bridge */ /* synthetic */ boolean add(Object obj) {
        d(((Long) obj).longValue());
        return true;
    }
}
