package o;

import com.google.android.gms.common.api.Api;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public abstract class GN extends YT {
    public static Object Y(Object obj, Map map) {
        Object obj2 = map.get(obj);
        if (obj2 != null || map.containsKey(obj)) {
            return obj2;
        }
        throw new NoSuchElementException("Key " + obj + " is missing in the map.");
    }

    public static int Z(int i) {
        return i < 0 ? i : i < 3 ? i + 1 : i < 1073741824 ? (int) ((i / 0.75f) + 1.0f) : Api.BaseClientBuilder.API_PRIORITY_OTHER;
    }

    public static Map a0(C3001yV... c3001yVArr) {
        if (c3001yVArr.length <= 0) {
            return C0358Nv.l;
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap(Z(c3001yVArr.length));
        b0(linkedHashMap, c3001yVArr);
        return linkedHashMap;
    }

    public static final void b0(HashMap map, C3001yV[] c3001yVArr) {
        for (C3001yV c3001yV : c3001yVArr) {
            map.put(c3001yV.l, c3001yV.m);
        }
    }

    public static Map c0(ArrayList arrayList) {
        int size = arrayList.size();
        if (size == 0) {
            return C0358Nv.l;
        }
        int i = 0;
        if (size == 1) {
            C3001yV c3001yV = (C3001yV) arrayList.get(0);
            return Collections.singletonMap(c3001yV.l, c3001yV.m);
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap(Z(arrayList.size()));
        int size2 = arrayList.size();
        while (i < size2) {
            Object obj = arrayList.get(i);
            i++;
            C3001yV c3001yV2 = (C3001yV) obj;
            linkedHashMap.put(c3001yV2.l, c3001yV2.m);
        }
        return linkedHashMap;
    }

    public static Map d0(Map map) {
        int size = map.size();
        if (size == 0) {
            return C0358Nv.l;
        }
        if (size != 1) {
            return new LinkedHashMap(map);
        }
        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
        return Collections.singletonMap(entry.getKey(), entry.getValue());
    }
}
