package com.google.android.gms.common.util;

import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.recaptcha.internal.a;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import n.C2578e;
import n.C2579f;

/* JADX INFO: loaded from: classes.dex */
@KeepForSdk
public final class CollectionUtils {
    private CollectionUtils() {
    }

    @KeepForSdk
    public static boolean isEmpty(Collection<?> collection) {
        if (collection == null) {
            return true;
        }
        return collection.isEmpty();
    }

    @KeepForSdk
    @Deprecated
    public static <T> List<T> listOf() {
        return Collections.EMPTY_LIST;
    }

    @KeepForSdk
    public static <K, V> Map<K, V> mapOf(K k6, V v3, K k7, V v6, K k8, V v7) {
        Map mapZza = zza(3, false);
        mapZza.put(k6, v3);
        mapZza.put(k7, v6);
        mapZza.put(k8, v7);
        return Collections.unmodifiableMap(mapZza);
    }

    @KeepForSdk
    public static <K, V> Map<K, V> mapOfKeyValueArrays(K[] kArr, V[] vArr) {
        int length = kArr.length;
        int length2 = vArr.length;
        if (length != length2) {
            throw new IllegalArgumentException(a.i(length, length2, "Key and values array lengths not equal: ", " != "));
        }
        if (length == 0) {
            return Collections.EMPTY_MAP;
        }
        if (length == 1) {
            return Collections.singletonMap(kArr[0], vArr[0]);
        }
        Map mapZza = zza(length, false);
        for (int i6 = 0; i6 < kArr.length; i6++) {
            mapZza.put(kArr[i6], vArr[i6]);
        }
        return Collections.unmodifiableMap(mapZza);
    }

    @KeepForSdk
    public static <T> Set<T> mutableSetOfWithSize(int i6) {
        return i6 == 0 ? new C2579f(0) : zzb(i6, true);
    }

    @KeepForSdk
    @Deprecated
    public static <T> Set<T> setOf(T t6, T t7, T t8) {
        Set setZzb = zzb(3, false);
        setZzb.add(t6);
        setZzb.add(t7);
        setZzb.add(t8);
        return Collections.unmodifiableSet(setZzb);
    }

    private static Map zza(int i6, boolean z6) {
        return i6 <= 256 ? new C2578e(i6) : new HashMap(i6, 1.0f);
    }

    private static Set zzb(int i6, boolean z6) {
        if (i6 <= (true != z6 ? 256 : 128)) {
            return new C2579f(i6);
        }
        return new HashSet(i6, true != z6 ? 1.0f : 0.75f);
    }

    @KeepForSdk
    @Deprecated
    public static <T> List<T> listOf(T t6) {
        return Collections.singletonList(t6);
    }

    @KeepForSdk
    @Deprecated
    public static <T> List<T> listOf(T... tArr) {
        int length = tArr.length;
        if (length == 0) {
            return Collections.EMPTY_LIST;
        }
        if (length != 1) {
            return Collections.unmodifiableList(Arrays.asList(tArr));
        }
        return Collections.singletonList(tArr[0]);
    }

    @KeepForSdk
    public static <K, V> Map<K, V> mapOf(K k6, V v3, K k7, V v6, K k8, V v7, K k9, V v8, K k10, V v9, K k11, V v10) {
        Map mapZza = zza(6, false);
        mapZza.put(k6, v3);
        mapZza.put(k7, v6);
        mapZza.put(k8, v7);
        mapZza.put(k9, v8);
        mapZza.put(k10, v9);
        mapZza.put(k11, v10);
        return Collections.unmodifiableMap(mapZza);
    }

    @KeepForSdk
    @Deprecated
    public static <T> Set<T> setOf(T... tArr) {
        int length = tArr.length;
        if (length == 0) {
            return Collections.EMPTY_SET;
        }
        if (length == 1) {
            return Collections.singleton(tArr[0]);
        }
        if (length == 2) {
            T t6 = tArr[0];
            T t7 = tArr[1];
            Set setZzb = zzb(2, false);
            setZzb.add(t6);
            setZzb.add(t7);
            return Collections.unmodifiableSet(setZzb);
        }
        if (length == 3) {
            return setOf(tArr[0], tArr[1], tArr[2]);
        }
        if (length != 4) {
            Set setZzb2 = zzb(length, false);
            Collections.addAll(setZzb2, tArr);
            return Collections.unmodifiableSet(setZzb2);
        }
        T t8 = tArr[0];
        T t9 = tArr[1];
        T t10 = tArr[2];
        T t11 = tArr[3];
        Set setZzb3 = zzb(4, false);
        setZzb3.add(t8);
        setZzb3.add(t9);
        setZzb3.add(t10);
        setZzb3.add(t11);
        return Collections.unmodifiableSet(setZzb3);
    }
}
