public static <K, V> V first(MapArray<K, V> map, JFuncTT<K, Boolean> func) {
   try {
     for (Pair<K, V> pair : map.pairs) if (func.invoke(pair.key)) return pair.value;
   } catch (Exception ignore) {
   }
   return null;
 }
 public static <T, T1> T1 first(Map<T, T1> map, JFuncTT<T, Boolean> func) {
   try {
     for (Map.Entry<T, T1> el : map.entrySet()) if (func.invoke(el.getKey())) return el.getValue();
   } catch (Exception ignore) {
   }
   return null;
 }
 public static <T> int firstIndex(T[] array, JFuncTT<T, Boolean> func) {
   try {
     for (int i = 0; i < array.length; i++) if (func.invoke(array[i])) return i;
   } catch (Exception ignore) {
   }
   return -1;
 }
 public static <T> int firstIndex(List<T> list, JFuncTT<T, Boolean> func) {
   try {
     for (int i = 0; i < list.size(); i++) if (func.invoke(list.get(i))) return i;
   } catch (Exception ignore) {
   }
   return -1;
 }
 public static <T> T first(Iterable<T> list, JFuncTT<T, Boolean> func) {
   try {
     for (T el : list) if (func.invoke(el)) return el;
   } catch (Exception ignore) {
   }
   return null;
 }
 public static <T> T last(Iterable<T> list, JFuncTT<T, Boolean> func) {
   T result = null;
   try {
     for (T el : list) if (func.invoke(el)) result = el;
   } catch (Exception ignore) {
   }
   return result;
 }
 public static <T> Collection<T> where(Iterable<T> list, JFuncTT<T, Boolean> func) {
   try {
     List<T> result = new ArrayList<>();
     for (T el : list) if (func.invoke(el)) result.add(el);
     return result;
   } catch (Exception ignore) {
     return new ArrayList<>();
   }
 }
 public static <T, T1> Collection<T1> select(Iterable<T> list, JFuncTT<T, T1> func) {
   try {
     List<T1> result = new ArrayList<>();
     for (T el : list) result.add(func.invoke(el));
     return result;
   } catch (Exception ignore) {
     return new ArrayList<>();
   }
 }
 public static <T, T1, T2> Map<T, T2> select(Map<T, T1> map, JFuncTT<T1, T2> func) {
   try {
     Map<T, T2> result = new HashMap<>();
     for (Map.Entry<T, T1> el : map.entrySet())
       result.put(el.getKey(), func.invoke(el.getValue()));
     return result;
   } catch (Exception ignore) {
     return new HashMap<>();
   }
 }