package io.sentry.util; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /* loaded from: classes3.dex */ public final class CollectionUtils { /* loaded from: classes3.dex */ public interface Mapper { R map(T t); } /* loaded from: classes3.dex */ public interface Predicate { boolean test(T t); } private CollectionUtils() { } public static int size(Iterable iterable) { if (iterable instanceof Collection) { return ((Collection) iterable).size(); } Iterator it = iterable.iterator(); int i = 0; while (it.hasNext()) { it.next(); i++; } return i; } public static Map newConcurrentHashMap(Map map) { if (map == null) { return null; } ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap(); for (Map.Entry entry : map.entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { concurrentHashMap.put(entry.getKey(), entry.getValue()); } } return concurrentHashMap; } public static Map newHashMap(Map map) { if (map != null) { return new HashMap(map); } return null; } public static List newArrayList(List list) { if (list != null) { return new ArrayList(list); } return null; } public static Map filterMapEntries(Map map, Predicate> predicate) { HashMap hashMap = new HashMap(); for (Map.Entry entry : map.entrySet()) { if (predicate.test(entry)) { hashMap.put(entry.getKey(), entry.getValue()); } } return hashMap; } public static List map(List list, Mapper mapper) { ArrayList arrayList = new ArrayList(list.size()); Iterator it = list.iterator(); while (it.hasNext()) { arrayList.add(mapper.map(it.next())); } return arrayList; } public static List filterListEntries(List list, Predicate predicate) { ArrayList arrayList = new ArrayList(list.size()); for (T t : list) { if (predicate.test(t)) { arrayList.add(t); } } return arrayList; } public static boolean contains(T[] tArr, T t) { for (T t2 : tArr) { if (t.equals(t2)) { return true; } } return false; } }