public final class IntFilterUtils
extends java.lang.Object
int primitives, without having to spell out the entire
stream->filter->collect process.| Modifier and Type | Method and Description |
|---|---|
static <C extends java.util.Collection<java.lang.Integer>> |
intFilter(int[] ints,
org.perro.functions.predicate.IntFilterCollector<C> filterCollector)
Filters an array of ints, based a predicate, into a collection.
|
static int[] |
intFilter(int[] ints,
java.util.function.IntPredicate predicate)
Filters an array of ints, based a predicate, into another int array.
|
static <C extends java.util.Collection<java.lang.Integer>> |
intFilterAndThen(java.util.function.IntPredicate filter,
java.util.stream.Collector<java.lang.Integer,?,C> collector)
Builds an object combining a
IntPredicate and a Collector for use in the intFilter(int[], IntFilterCollector) method. |
static <C extends java.util.Collection<java.lang.Integer>> |
intFilterDistinct(int[] ints,
org.perro.functions.predicate.IntFilterCollector<C> filterCollector)
Filters an array of ints, based a predicate, into an array of distinct
int values. |
static int[] |
intFilterDistinct(int[] ints,
java.util.function.IntPredicate predicate)
Filters an array of ints, based a predicate, into an array of distinct
int values (according to
Integer.compare(int, int)). |
static java.util.Set<java.lang.Integer> |
intFilterToSet(int[] ints,
java.util.function.IntPredicate predicate)
Filters an array of ints, based a predicate, into a set.
|
public static int[] intFilter(int[] ints,
java.util.function.IntPredicate predicate)
ints - An array of ints to be filtered.predicate - A predicate with which to filter the ints array.public static java.util.Set<java.lang.Integer> intFilterToSet(int[] ints,
java.util.function.IntPredicate predicate)
ints - An array of ints to be filtered.predicate - A predicate with which to filter the ints array.public static int[] intFilterDistinct(int[] ints,
java.util.function.IntPredicate predicate)
int values (according to
Integer.compare(int, int)).ints - An array of ints to be filtered.predicate - A predicate with which to filter the ints array.public static <C extends java.util.Collection<java.lang.Integer>> C intFilter(int[] ints,
org.perro.functions.predicate.IntFilterCollector<C> filterCollector)
intFilterAndThen(IntPredicate, Collector) method, which allows you to specify both a
predicate and a Collector to build any type of Collection as a result. For
example:
int[] ints = ...
List<Integer> = IntFilterUtils.intFilter(ints, FilterUtils.intFilterAndThen(IntPredicateUtils.intGt(1.0D), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
intFilter(ints, intFilterAndThen(intGt(1.0D), toCollection(LinkedList::new)));
C - The type of the resulting Collection.ints - An array of ints to be filtered.filterCollector - An object containing a predicate with which to filter the ints array, and a Collector
to accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Integer>> C intFilterDistinct(int[] ints,
org.perro.functions.predicate.IntFilterCollector<C> filterCollector)
int values. This overload
takes an object that is built using the intFilterAndThen(IntPredicate, Collector) method, which allows
you to specify both an IntPredicate and a Collector to build any type of
Collection as a result. For example:
int[] ints = ...
List<Integer> = IntFilterUtils.intFilter(ints, IntFilterUtils.intFilterAndThen(IntPredicateUtils.intGt(1), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
List<Integer> = intFilter(ints, intFilterAndThen(intGt(1), toCollection(LinkedList::new)));
C - The type of the resulting Collection.ints - An array of ints to be filtered.filterCollector - An object containing a predicate with which to filter the ints array, and a Collector to
accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Integer>> org.perro.functions.predicate.IntFilterCollector<C> intFilterAndThen(java.util.function.IntPredicate filter,
java.util.stream.Collector<java.lang.Integer,?,C> collector)
IntPredicate and a Collector for use in the intFilter(int[], IntFilterCollector) method.C - The type of the resulting collection.filter - A Predicate for filtering elements from an array of ints.collector - A Collector to accumulate elements into a Collection of Integer objects.