/** * Retains all elements in input collection that are evaluated to {@code true} * by all given predicates. * * @param c Input collection. * @param cp If {@code true} method creates collection not modifying input, otherwise does * <tt>in-place</tt> modifications. * @param p Predicates to filter by. If no predicates provides - all elements * will be retained. * @param <T> Type of collections. * @return Collection of retain elements. */ public static <T> Collection<T> retain(Collection<T> c, boolean cp, @Nullable IgnitePredicate<? super T>... p) { A.notNull(c, "c"); return lose(c, cp, not(p)); }
/** * Loses all elements in input collection that are contained in {@code filter} collection. * * @param c Input collection. * @param cp If {@code true} method creates new collection not modifying input, * otherwise does <tt>in-place</tt> modifications. * @param filter Filter collection. If {@code filter} collection is empty or * {@code null} - no elements are lost. * @param <T> Type of collections. * @return Collection of remaining elements */ public static <T0, T extends T0> Collection<T> lose(Collection<T> c, boolean cp, @Nullable Collection<T0> filter) { A.notNull(c, "c"); return lose(c, cp, F0.in(filter)); }
/** * Loses all elements in input collection that are contained in {@code filter} collection. * * @param c Input collection. * @param cp If {@code true} method creates new collection not modifying input, * otherwise does <tt>in-place</tt> modifications. * @param filter Filter collection. If {@code filter} collection is empty or * {@code null} - no elements are lost. * @param <T> Type of collections. * @return Collection of remaining elements */ public static <T0, T extends T0> Collection<T> lose(Collection<T> c, boolean cp, @Nullable Collection<T0> filter) { A.notNull(c, "c"); return lose(c, cp, F0.in(filter)); }
/** * Retains all elements in input collection that are evaluated to {@code true} * by all given predicates. * * @param c Input collection. * @param cp If {@code true} method creates collection not modifying input, otherwise does * <tt>in-place</tt> modifications. * @param p Predicates to filter by. If no predicates provides - all elements * will be retained. * @param <T> Type of collections. * @return Collection of retain elements. */ public static <T> Collection<T> retain(Collection<T> c, boolean cp, @Nullable IgnitePredicate<? super T>... p) { A.notNull(c, "c"); return lose(c, cp, not(p)); }