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

import java.util.Arrays;

/* JADX INFO: loaded from: classes2.dex */
public final class g7 {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final g7 f20204f = new g7(0, new int[0], new Object[0], false);

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object[] f20207c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f20208d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f20209e;

    public g7(int i10, int[] iArr, Object[] objArr, boolean z10) {
        this.f20205a = i10;
        this.f20206b = iArr;
        this.f20207c = objArr;
        this.f20209e = z10;
    }

    public static g7 e() {
        return new g7(0, new int[8], new Object[8], true);
    }

    public final int a() {
        int iE;
        int i10 = this.f20208d;
        if (i10 != -1) {
            return i10;
        }
        int iA = 0;
        for (int i11 = 0; i11 < this.f20205a; i11++) {
            int i12 = this.f20206b[i11];
            int i13 = i12 >>> 3;
            int i14 = i12 & 7;
            if (i14 == 0) {
                iE = u5.E(i13, ((Long) this.f20207c[i11]).longValue());
            } else if (i14 == 1) {
                ((Long) this.f20207c[i11]).longValue();
                iE = u5.s(i13);
            } else if (i14 == 2) {
                iE = u5.t(i13, (zzik) this.f20207c[i11]);
            } else if (i14 == 3) {
                iA = ((g7) this.f20207c[i11]).a() + (u5.H(i13) << 1) + iA;
            } else {
                if (i14 != 5) {
                    int i15 = zzkb.f20654a;
                    throw new IllegalStateException(new zzke("Protocol message tag had invalid wire type."));
                }
                ((Integer) this.f20207c[i11]).intValue();
                iE = u5.B(i13);
            }
            iA = iE + iA;
        }
        this.f20208d = iA;
        return iA;
    }

    public final void b(int i10) {
        int[] iArr = this.f20206b;
        if (i10 > iArr.length) {
            int i11 = this.f20205a;
            int i12 = (i11 / 2) + i11;
            if (i12 >= i10) {
                i10 = i12;
            }
            if (i10 < 8) {
                i10 = 8;
            }
            this.f20206b = Arrays.copyOf(iArr, i10);
            this.f20207c = Arrays.copyOf(this.f20207c, i10);
        }
    }

    public final void c(int i10, Object obj) {
        if (!this.f20209e) {
            throw new UnsupportedOperationException();
        }
        b(this.f20205a + 1);
        int[] iArr = this.f20206b;
        int i11 = this.f20205a;
        iArr[i11] = i10;
        this.f20207c[i11] = obj;
        this.f20205a = i11 + 1;
    }

    public final void d(xyz.stream.api.a0 a0Var) {
        if (this.f20205a == 0) {
            return;
        }
        a0Var.getClass();
        for (int i10 = 0; i10 < this.f20205a; i10++) {
            int i11 = this.f20206b[i10];
            Object obj = this.f20207c[i10];
            int i12 = i11 >>> 3;
            int i13 = i11 & 7;
            if (i13 == 0) {
                a0Var.x(i12, ((Long) obj).longValue());
            } else if (i13 == 1) {
                a0Var.n(i12, ((Long) obj).longValue());
            } else if (i13 == 2) {
                a0Var.r(i12, (zzik) obj);
            } else if (i13 == 3) {
                a0Var.z(i12);
                ((g7) obj).d(a0Var);
                a0Var.v(i12);
            } else {
                if (i13 != 5) {
                    throw new RuntimeException(zzkb.a());
                }
                a0Var.w(i12, ((Integer) obj).intValue());
            }
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof g7)) {
            return false;
        }
        g7 g7Var = (g7) obj;
        int i10 = this.f20205a;
        if (i10 == g7Var.f20205a) {
            int[] iArr = this.f20206b;
            int[] iArr2 = g7Var.f20206b;
            int i11 = 0;
            while (true) {
                if (i11 >= i10) {
                    Object[] objArr = this.f20207c;
                    Object[] objArr2 = g7Var.f20207c;
                    int i12 = this.f20205a;
                    for (int i13 = 0; i13 < i12; i13++) {
                        if (objArr[i13].equals(objArr2[i13])) {
                        }
                    }
                    return true;
                }
                if (iArr[i11] != iArr2[i11]) {
                    break;
                }
                i11++;
            }
        }
        return false;
    }

    public final int hashCode() {
        int i10 = this.f20205a;
        int i11 = (i10 + 527) * 31;
        int[] iArr = this.f20206b;
        int iHashCode = 17;
        int i12 = 17;
        for (int i13 = 0; i13 < i10; i13++) {
            i12 = (i12 * 31) + iArr[i13];
        }
        int i14 = (i11 + i12) * 31;
        Object[] objArr = this.f20207c;
        int i15 = this.f20205a;
        for (int i16 = 0; i16 < i15; i16++) {
            iHashCode = (iHashCode * 31) + objArr[i16].hashCode();
        }
        return i14 + iHashCode;
    }
}
