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

import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Object[] f21100a = new Object[8];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f21101b = 0;

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

    public final void a(Object obj, Object obj2) {
        d(this.f21101b + 1);
        q9.u(obj, obj2);
        Object[] objArr = this.f21100a;
        int i10 = this.f21101b;
        int i11 = i10 + i10;
        objArr[i11] = obj;
        objArr[i11 + 1] = obj2;
        this.f21101b = i10 + 1;
    }

    public final void b(Map map) {
        Set<Map.Entry> setEntrySet = map.entrySet();
        if (setEntrySet instanceof Collection) {
            d(setEntrySet.size() + this.f21101b);
        }
        for (Map.Entry entry : setEntrySet) {
            a(entry.getKey(), entry.getValue());
        }
    }

    public final zzjc c() {
        m6 m6Var = this.f21102c;
        if (m6Var != null) {
            throw m6Var.a();
        }
        zzjj zzjjVarJ = zzjj.j(this.f21101b, this.f21100a, this);
        m6 m6Var2 = this.f21102c;
        if (m6Var2 == null) {
            return zzjjVarJ;
        }
        throw m6Var2.a();
    }

    public final void d(int i10) {
        int i11 = i10 + i10;
        Object[] objArr = this.f21100a;
        int length = objArr.length;
        if (i11 > length) {
            int i12 = length + (length >> 1) + 1;
            if (i12 < i11) {
                int iHighestOneBit = Integer.highestOneBit(i11 - 1);
                i12 = iHighestOneBit + iHighestOneBit;
            }
            if (i12 < 0) {
                i12 = Integer.MAX_VALUE;
            }
            this.f21100a = Arrays.copyOf(objArr, i12);
        }
    }
}
