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 v extends c implements z.f, RandomAccess, b1 {

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

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

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

    private v(float[] fArr, int i10, boolean z10) {
        super(z10);
        this.f15229q = fArr;
        this.f15230r = i10;
    }

    private void l(int i10, float f10) {
        int i11;
        e();
        if (i10 < 0 || i10 > (i11 = this.f15230r)) {
            throw new IndexOutOfBoundsException(r(i10));
        }
        float[] fArr = this.f15229q;
        if (i11 < fArr.length) {
            System.arraycopy(fArr, i10, fArr, i10 + 1, i11 - i10);
        } else {
            float[] fArr2 = new float[((i11 * 3) / 2) + 1];
            System.arraycopy(fArr, 0, fArr2, 0, i10);
            System.arraycopy(this.f15229q, i10, fArr2, i10 + 1, this.f15230r - i10);
            this.f15229q = fArr2;
        }
        this.f15229q[i10] = f10;
        this.f15230r++;
        ((AbstractList) this).modCount++;
    }

    public static v m() {
        return f15228s;
    }

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

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

    @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 v)) {
            return super.addAll(collection);
        }
        v vVar = (v) collection;
        int i10 = vVar.f15230r;
        if (i10 == 0) {
            return false;
        }
        int i11 = this.f15230r;
        if (Api.BaseClientBuilder.API_PRIORITY_OTHER - i11 < i10) {
            throw new OutOfMemoryError();
        }
        int i12 = i11 + i10;
        float[] fArr = this.f15229q;
        if (i12 > fArr.length) {
            this.f15229q = Arrays.copyOf(fArr, i12);
        }
        System.arraycopy(vVar.f15229q, 0, this.f15229q, this.f15230r, vVar.f15230r);
        this.f15230r = 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 v)) {
            return super.equals(obj);
        }
        v vVar = (v) obj;
        if (this.f15230r != vVar.f15230r) {
            return false;
        }
        float[] fArr = vVar.f15229q;
        for (int i10 = 0; i10 < this.f15230r; i10++) {
            if (Float.floatToIntBits(this.f15229q[i10]) != Float.floatToIntBits(fArr[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, Float f10) {
        l(i10, f10.floatValue());
    }

    @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.f15230r; i11++) {
            i10 = (i10 * 31) + Float.floatToIntBits(this.f15229q[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(Float f10) {
        k(f10.floatValue());
        return true;
    }

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

    public void k(float f10) {
        e();
        int i10 = this.f15230r;
        float[] fArr = this.f15229q;
        if (i10 == fArr.length) {
            float[] fArr2 = new float[((i10 * 3) / 2) + 1];
            System.arraycopy(fArr, 0, fArr2, 0, i10);
            this.f15229q = fArr2;
        }
        float[] fArr3 = this.f15229q;
        int i11 = this.f15230r;
        this.f15230r = i11 + 1;
        fArr3[i11] = f10;
    }

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

    public float q(int i10) {
        n(i10);
        return this.f15229q[i10];
    }

    @Override // java.util.AbstractList
    protected void removeRange(int i10, int i11) {
        e();
        if (i11 < i10) {
            throw new IndexOutOfBoundsException("toIndex < fromIndex");
        }
        float[] fArr = this.f15229q;
        System.arraycopy(fArr, i11, fArr, i10, this.f15230r - i11);
        this.f15230r -= 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 Float remove(int i10) {
        e();
        n(i10);
        float[] fArr = this.f15229q;
        float f10 = fArr[i10];
        if (i10 < this.f15230r - 1) {
            System.arraycopy(fArr, i10 + 1, fArr, i10, (r2 - i10) - 1);
        }
        this.f15230r--;
        ((AbstractList) this).modCount++;
        return Float.valueOf(f10);
    }

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

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

    public float v(int i10, float f10) {
        e();
        n(i10);
        float[] fArr = this.f15229q;
        float f11 = fArr[i10];
        fArr[i10] = f10;
        return f11;
    }

    @Override // com.google.protobuf.z.j
    public z.f a(int i10) {
        if (i10 >= this.f15230r) {
            return new v(Arrays.copyOf(this.f15229q, i10), this.f15230r, true);
        }
        throw new IllegalArgumentException();
    }
}
