/** * Loses all elements in input list for which any of the predicates evaluate to {@code true}. * * @param c Input list. * @param cp If {@code true} method creates new list not modifying input, * otherwise does <tt>in-place</tt> modifications. * @param p Looses all elements for which any of the predicates evaluate to {@code true}. * @param <T> Type of list. * @return List of remaining elements */ @Deprecated public static <T> List<T> filterList(List<T> c, boolean cp, @Nullable IgnitePredicate<T>... p) { A.notNull(c, "c"); List<T> res; if (!cp) { res = c; if (p != null) for (Iterator<T> it = c.iterator(); it.hasNext();) if (isAny(it.next(), p)) it.remove(); } else { res = new ArrayList<>(c.size()); for (T t : c) if (!isAny(t, p)) res.add(t); } return res; }
/** * Finds and returns first element in given collection for which any of the * provided predicates evaluates to {@code true}. * * @param c Input collection. * @param dfltVal Default value to return when no element is found. * @param p Optional set of finder predicates. * @param <V> Type of the collection elements. * @return First element in given collection for which predicate evaluates to * {@code true} - or {@code null} if such element cannot be found. */ @SafeVarargs @Nullable public static <V> V find(Iterable<? extends V> c, @Nullable V dfltVal, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c"); if (!isEmpty(p) && !isAlwaysFalse(p)) { for (V v : c) { if (isAny(v, p)) return v; } } return dfltVal; }
/** * Finds, transforms and returns first element in given collection for which any of * the provided predicates evaluates to {@code true}. * * @param c Input collection. * @param dfltVal Default value to return when no element is found. * @param f Transforming closure. * @param p Optional set of finder predicates. * @param <V> Type of the collection elements. * @return First element in given collection for which predicate evaluates to * {@code true} - or {@code null} if such element cannot be found. */ @Deprecated public static <V, Y> Y find(Iterable<? extends V> c, @Nullable Y dfltVal, IgniteClosure<? super V, Y> f, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c", f, "f"); if (isAlwaysTrue(p) && c.iterator().hasNext()) return f.apply(c.iterator().next()); if (!isEmpty(p) && !isAlwaysFalse(p)) { for (V v : c) { if (isAny(v, p)) return f.apply(v); } } return dfltVal; }
/** * Loses all elements in input list for which any of the predicates evaluate to {@code true}. * * @param c Input list. * @param cp If {@code true} method creates new list not modifying input, * otherwise does <tt>in-place</tt> modifications. * @param p Looses all elements for which any of the predicates evaluate to {@code true}. * @param <T> Type of list. * @return List of remaining elements */ @Deprecated public static <T> List<T> filterList(List<T> c, boolean cp, @Nullable IgnitePredicate<T>... p) { A.notNull(c, "c"); List<T> res; if (!cp) { res = c; if (p != null) for (Iterator<T> it = c.iterator(); it.hasNext();) if (isAny(it.next(), p)) it.remove(); } else { res = new ArrayList<>(c.size()); for (T t : c) if (!isAny(t, p)) res.add(t); } return res; }
/** * Finds and returns first element in given collection for which any of the * provided predicates evaluates to {@code true}. * * @param c Input collection. * @param dfltVal Default value to return when no element is found. * @param p Optional set of finder predicates. * @param <V> Type of the collection elements. * @return First element in given collection for which predicate evaluates to * {@code true} - or {@code null} if such element cannot be found. */ @SafeVarargs @Nullable public static <V> V find(Iterable<? extends V> c, @Nullable V dfltVal, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c"); if (!isEmpty(p) && !isAlwaysFalse(p)) { for (V v : c) { if (isAny(v, p)) return v; } } return dfltVal; }
/** * Finds, transforms and returns first element in given collection for which any of * the provided predicates evaluates to {@code true}. * * @param c Input collection. * @param dfltVal Default value to return when no element is found. * @param f Transforming closure. * @param p Optional set of finder predicates. * @param <V> Type of the collection elements. * @return First element in given collection for which predicate evaluates to * {@code true} - or {@code null} if such element cannot be found. */ @Deprecated public static <V, Y> Y find(Iterable<? extends V> c, @Nullable Y dfltVal, IgniteClosure<? super V, Y> f, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c", f, "f"); if (isAlwaysTrue(p) && c.iterator().hasNext()) return f.apply(c.iterator().next()); if (!isEmpty(p) && !isAlwaysFalse(p)) { for (V v : c) { if (isAny(v, p)) return f.apply(v); } } return dfltVal; }