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: loaded from: classes3.dex */
public final class E extends AbstractC1300d implements V, RandomAccess, C0 {

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

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

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

    public E(float[] fArr, int i6, boolean z6) {
        super(z6);
        this.f14173b = fArr;
        this.f14174c = i6;
    }

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

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i6, Object obj) {
        int i7;
        float fFloatValue = ((Float) obj).floatValue();
        e();
        if (i6 < 0 || i6 > (i7 = this.f14174c)) {
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
            sbR.append(this.f14174c);
            throw new IndexOutOfBoundsException(sbR.toString());
        }
        float[] fArr = this.f14173b;
        if (i7 < fArr.length) {
            System.arraycopy(fArr, i6, fArr, i6 + 1, i7 - i6);
        } else {
            float[] fArr2 = new float[Z0.o.A(i7, 3, 2, 1)];
            System.arraycopy(fArr, 0, fArr2, 0, i6);
            System.arraycopy(this.f14173b, i6, fArr2, i6 + 1, this.f14174c - i6);
            this.f14173b = fArr2;
        }
        this.f14173b[i6] = fFloatValue;
        this.f14174c++;
        ((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 E)) {
            return super.addAll(collection);
        }
        E e6 = (E) collection;
        int i6 = e6.f14174c;
        if (i6 == 0) {
            return false;
        }
        int i7 = this.f14174c;
        if (Integer.MAX_VALUE - i7 < i6) {
            throw new OutOfMemoryError();
        }
        int i8 = i7 + i6;
        float[] fArr = this.f14173b;
        if (i8 > fArr.length) {
            this.f14173b = Arrays.copyOf(fArr, i8);
        }
        System.arraycopy(e6.f14173b, 0, this.f14173b, this.f14174c, e6.f14174c);
        this.f14174c = 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 E)) {
            return super.equals(obj);
        }
        E e6 = (E) obj;
        if (this.f14174c != e6.f14174c) {
            return false;
        }
        float[] fArr = e6.f14173b;
        for (int i6 = 0; i6 < this.f14174c; i6++) {
            if (Float.floatToIntBits(this.f14173b[i6]) != Float.floatToIntBits(fArr[i6])) {
                return false;
            }
        }
        return true;
    }

    public final void g(float f6) {
        e();
        int i6 = this.f14174c;
        float[] fArr = this.f14173b;
        if (i6 == fArr.length) {
            float[] fArr2 = new float[Z0.o.A(i6, 3, 2, 1)];
            System.arraycopy(fArr, 0, fArr2, 0, i6);
            this.f14173b = fArr2;
        }
        float[] fArr3 = this.f14173b;
        int i7 = this.f14174c;
        this.f14174c = i7 + 1;
        fArr3[i7] = f6;
    }

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

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

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.Collection, java.util.List
    public final int hashCode() {
        int iFloatToIntBits = 1;
        for (int i6 = 0; i6 < this.f14174c; i6++) {
            iFloatToIntBits = (iFloatToIntBits * 31) + Float.floatToIntBits(this.f14173b[i6]);
        }
        return iFloatToIntBits;
    }

    @Override // java.util.AbstractList, java.util.List
    public final int indexOf(Object obj) {
        if (!(obj instanceof Float)) {
            return -1;
        }
        float fFloatValue = ((Float) obj).floatValue();
        int i6 = this.f14174c;
        for (int i7 = 0; i7 < i6; i7++) {
            if (this.f14173b[i7] == fFloatValue) {
                return i7;
            }
        }
        return -1;
    }

    @Override // com.google.protobuf.AbstractC1300d, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        h(i6);
        float[] fArr = this.f14173b;
        float f6 = fArr[i6];
        if (i6 < this.f14174c - 1) {
            System.arraycopy(fArr, i6 + 1, fArr, i6, (r2 - i6) - 1);
        }
        this.f14174c--;
        ((AbstractList) this).modCount++;
        return Float.valueOf(f6);
    }

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

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i6, Object obj) {
        float fFloatValue = ((Float) obj).floatValue();
        e();
        h(i6);
        float[] fArr = this.f14173b;
        float f6 = fArr[i6];
        fArr[i6] = fFloatValue;
        return Float.valueOf(f6);
    }

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

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