- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
170 lines
4.7 KiB
Java
170 lines
4.7 KiB
Java
package com.google.android.gms.common.util;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.collection.ArrayMap;
|
|
import androidx.collection.ArraySet;
|
|
import com.google.android.gms.common.annotation.KeepForSdk;
|
|
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;
|
|
|
|
@KeepForSdk
|
|
/* loaded from: classes2.dex */
|
|
public final class CollectionUtils {
|
|
private CollectionUtils() {
|
|
}
|
|
|
|
@KeepForSdk
|
|
public static boolean isEmpty(@Nullable Collection<?> collection) {
|
|
if (collection == null) {
|
|
return true;
|
|
}
|
|
return collection.isEmpty();
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
@Deprecated
|
|
public static <T> List<T> listOf() {
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static <K, V> Map<K, V> mapOf(@NonNull K k, @NonNull V v, @NonNull K k2, @NonNull V v2, @NonNull K k3, @NonNull V v3) {
|
|
Map zza = zza(3, false);
|
|
zza.put(k, v);
|
|
zza.put(k2, v2);
|
|
zza.put(k3, v3);
|
|
return Collections.unmodifiableMap(zza);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static <K, V> Map<K, V> mapOfKeyValueArrays(@NonNull K[] kArr, @NonNull V[] vArr) {
|
|
int length = kArr.length;
|
|
int length2 = vArr.length;
|
|
if (length != length2) {
|
|
throw new IllegalArgumentException("Key and values array lengths not equal: " + length + " != " + length2);
|
|
}
|
|
if (length == 0) {
|
|
return Collections.emptyMap();
|
|
}
|
|
if (length == 1) {
|
|
return Collections.singletonMap(kArr[0], vArr[0]);
|
|
}
|
|
Map zza = zza(length, false);
|
|
for (int i = 0; i < kArr.length; i++) {
|
|
zza.put(kArr[i], vArr[i]);
|
|
}
|
|
return Collections.unmodifiableMap(zza);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static <T> Set<T> mutableSetOfWithSize(int i) {
|
|
return i == 0 ? new ArraySet() : zzb(i, true);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
@Deprecated
|
|
public static <T> Set<T> setOf(@NonNull T t, @NonNull T t2, @NonNull T t3) {
|
|
Set zzb = zzb(3, false);
|
|
zzb.add(t);
|
|
zzb.add(t2);
|
|
zzb.add(t3);
|
|
return Collections.unmodifiableSet(zzb);
|
|
}
|
|
|
|
private static Map zza(int i, boolean z) {
|
|
return i <= 256 ? new ArrayMap(i) : new HashMap(i, 1.0f);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
@Deprecated
|
|
public static <T> List<T> listOf(@NonNull T t) {
|
|
return Collections.singletonList(t);
|
|
}
|
|
|
|
private static Set zzb(int i, boolean z) {
|
|
if (i <= (true != z ? 256 : 128)) {
|
|
return new ArraySet(i);
|
|
}
|
|
return new HashSet(i, true != z ? 1.0f : 0.75f);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
@Deprecated
|
|
public static <T> List<T> listOf(@NonNull T... tArr) {
|
|
int length = tArr.length;
|
|
if (length == 0) {
|
|
return Collections.emptyList();
|
|
}
|
|
if (length == 1) {
|
|
return Collections.singletonList(tArr[0]);
|
|
}
|
|
return Collections.unmodifiableList(Arrays.asList(tArr));
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static <K, V> Map<K, V> mapOf(@NonNull K k, @NonNull V v, @NonNull K k2, @NonNull V v2, @NonNull K k3, @NonNull V v3, @NonNull K k4, @NonNull V v4, @NonNull K k5, @NonNull V v5, @NonNull K k6, @NonNull V v6) {
|
|
Map zza = zza(6, false);
|
|
zza.put(k, v);
|
|
zza.put(k2, v2);
|
|
zza.put(k3, v3);
|
|
zza.put(k4, v4);
|
|
zza.put(k5, v5);
|
|
zza.put(k6, v6);
|
|
return Collections.unmodifiableMap(zza);
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
@Deprecated
|
|
public static <T> Set<T> setOf(@NonNull T... tArr) {
|
|
int length = tArr.length;
|
|
if (length == 0) {
|
|
return Collections.emptySet();
|
|
}
|
|
if (length == 1) {
|
|
return Collections.singleton(tArr[0]);
|
|
}
|
|
if (length == 2) {
|
|
T t = tArr[0];
|
|
T t2 = tArr[1];
|
|
Set zzb = zzb(2, false);
|
|
zzb.add(t);
|
|
zzb.add(t2);
|
|
return Collections.unmodifiableSet(zzb);
|
|
}
|
|
if (length == 3) {
|
|
return setOf(tArr[0], tArr[1], tArr[2]);
|
|
}
|
|
if (length == 4) {
|
|
T t3 = tArr[0];
|
|
T t4 = tArr[1];
|
|
T t5 = tArr[2];
|
|
T t6 = tArr[3];
|
|
Set zzb2 = zzb(4, false);
|
|
zzb2.add(t3);
|
|
zzb2.add(t4);
|
|
zzb2.add(t5);
|
|
zzb2.add(t6);
|
|
return Collections.unmodifiableSet(zzb2);
|
|
}
|
|
Set zzb3 = zzb(length, false);
|
|
Collections.addAll(zzb3, tArr);
|
|
return Collections.unmodifiableSet(zzb3);
|
|
}
|
|
}
|