package com.google.android.gms.internal.measurement;

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

/* JADX INFO: loaded from: classes2.dex */
public final class m6 extends o5 implements h6, z6, RandomAccess {

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

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

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

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

    static {
        long[] jArr = new long[0];
        f20312d = jArr;
        f20313e = new m6(jArr, 0, false);
    }

    public m6(long[] jArr, int i10, boolean z10) {
        super(z10);
        this.f20314b = jArr;
        this.f20315c = i10;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i10, Object obj) {
        int i11;
        long jLongValue = ((Long) obj).longValue();
        zza();
        if (i10 < 0 || i10 > (i11 = this.f20315c)) {
            throw new IndexOutOfBoundsException(defpackage.e.f("Index:", i10, ", Size:", this.f20315c));
        }
        long[] jArr = this.f20314b;
        if (i11 < jArr.length) {
            System.arraycopy(jArr, i10, jArr, i10 + 1, i11 - i10);
        } else {
            long[] jArr2 = new long[com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(jArr.length, 3, 2, 1, 10)];
            System.arraycopy(this.f20314b, 0, jArr2, 0, i10);
            System.arraycopy(this.f20314b, i10, jArr2, i10 + 1, this.f20315c - i10);
            this.f20314b = jArr2;
        }
        this.f20314b[i10] = jLongValue;
        this.f20315c++;
        ((AbstractList) this).modCount++;
    }

    @Override // com.google.android.gms.internal.measurement.o5, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean addAll(Collection collection) {
        zza();
        Charset charset = d6.f20163a;
        collection.getClass();
        if (!(collection instanceof m6)) {
            return super.addAll(collection);
        }
        m6 m6Var = (m6) collection;
        int i10 = m6Var.f20315c;
        if (i10 == 0) {
            return false;
        }
        int i11 = this.f20315c;
        if (Integer.MAX_VALUE - i11 < i10) {
            throw new OutOfMemoryError();
        }
        int i12 = i11 + i10;
        long[] jArr = this.f20314b;
        if (i12 > jArr.length) {
            this.f20314b = Arrays.copyOf(jArr, i12);
        }
        System.arraycopy(m6Var.f20314b, 0, this.f20314b, this.f20315c, m6Var.f20315c);
        this.f20315c = i12;
        ((AbstractList) this).modCount++;
        return true;
    }

    public final void c(long j10) {
        zza();
        int i10 = this.f20315c;
        long[] jArr = this.f20314b;
        if (i10 == jArr.length) {
            long[] jArr2 = new long[com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(jArr.length, 3, 2, 1, 10)];
            System.arraycopy(this.f20314b, 0, jArr2, 0, this.f20315c);
            this.f20314b = jArr2;
        }
        long[] jArr3 = this.f20314b;
        int i11 = this.f20315c;
        this.f20315c = i11 + 1;
        jArr3[i11] = j10;
    }

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

    @Override // com.google.android.gms.internal.measurement.o5, java.util.AbstractList, java.util.Collection, java.util.List
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof m6)) {
            return super.equals(obj);
        }
        m6 m6Var = (m6) obj;
        if (this.f20315c != m6Var.f20315c) {
            return false;
        }
        long[] jArr = m6Var.f20314b;
        for (int i10 = 0; i10 < this.f20315c; i10++) {
            if (this.f20314b[i10] != jArr[i10]) {
                return false;
            }
        }
        return true;
    }

    public final long f(int i10) {
        i(i10);
        return this.f20314b[i10];
    }

    @Override // com.google.android.gms.internal.measurement.k6
    /* JADX INFO: renamed from: g, reason: merged with bridge method [inline-methods] */
    public final m6 zza(int i10) {
        if (i10 >= this.f20315c) {
            return new m6(i10 == 0 ? f20312d : Arrays.copyOf(this.f20314b, i10), this.f20315c, true);
        }
        throw new IllegalArgumentException();
    }

    @Override // java.util.AbstractList, java.util.List
    public final /* synthetic */ Object get(int i10) {
        return Long.valueOf(f(i10));
    }

    public final void h(int i10) {
        long[] jArr = this.f20314b;
        if (i10 <= jArr.length) {
            return;
        }
        if (jArr.length == 0) {
            this.f20314b = new long[Math.max(i10, 10)];
            return;
        }
        int length = jArr.length;
        while (length < i10) {
            length = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.c(length, 3, 2, 1, 10);
        }
        this.f20314b = Arrays.copyOf(this.f20314b, length);
    }

    @Override // com.google.android.gms.internal.measurement.o5, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int iA = 1;
        for (int i10 = 0; i10 < this.f20315c; i10++) {
            iA = (iA * 31) + d6.a(this.f20314b[i10]);
        }
        return iA;
    }

    public final void i(int i10) {
        if (i10 < 0 || i10 >= this.f20315c) {
            throw new IndexOutOfBoundsException(defpackage.e.f("Index:", i10, ", Size:", this.f20315c));
        }
    }

    @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 i10 = this.f20315c;
        for (int i11 = 0; i11 < i10; i11++) {
            if (this.f20314b[i11] == jLongValue) {
                return i11;
            }
        }
        return -1;
    }

    @Override // com.google.android.gms.internal.measurement.o5, java.util.AbstractList, java.util.List
    public final /* synthetic */ Object remove(int i10) {
        zza();
        i(i10);
        long[] jArr = this.f20314b;
        long j10 = jArr[i10];
        if (i10 < this.f20315c - 1) {
            System.arraycopy(jArr, i10 + 1, jArr, i10, (r3 - i10) - 1);
        }
        this.f20315c--;
        ((AbstractList) this).modCount++;
        return Long.valueOf(j10);
    }

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

    @Override // java.util.AbstractList, java.util.List
    public final /* synthetic */ Object set(int i10, Object obj) {
        long jLongValue = ((Long) obj).longValue();
        zza();
        i(i10);
        long[] jArr = this.f20314b;
        long j10 = jArr[i10];
        jArr[i10] = jLongValue;
        return Long.valueOf(j10);
    }

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

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