public final class DblFilterUtils
extends java.lang.Object
double 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.Double>> |
dblFilter(double[] doubles,
org.perro.functions.predicate.DoubleFilterCollector<C> filterCollector)
Filters an array of doubles, based a predicate, into a collection.
|
static double[] |
dblFilter(double[] doubles,
java.util.function.DoublePredicate predicate)
Filters an array of doubles, based a predicate, into another double array.
|
static <C extends java.util.Collection<java.lang.Double>> |
dblFilterAndThen(java.util.function.DoublePredicate filter,
java.util.stream.Collector<java.lang.Double,?,C> collector)
Builds an object combining a
DoublePredicate and a Collector for use in the dblFilter(double[], DoubleFilterCollector) method. |
static <C extends java.util.Collection<java.lang.Double>> |
dblFilterDistinct(double[] doubles,
org.perro.functions.predicate.DoubleFilterCollector<C> filterCollector)
Filters an array of doubles, based a predicate, into an array of distinct
double values. |
static double[] |
dblFilterDistinct(double[] doubles,
java.util.function.DoublePredicate predicate)
Filters an array of doubles, based a predicate, into an array of distinct
double values (according
to Double.compare(double, double)). |
static java.util.Set<java.lang.Double> |
dblFilterToSet(double[] doubles,
java.util.function.DoublePredicate predicate)
Filters an array of doubles, based a predicate, into a set.
|
public static double[] dblFilter(double[] doubles,
java.util.function.DoublePredicate predicate)
doubles - An array of doubles to be filtered.predicate - A predicate with which to filter the doubles array.public static java.util.Set<java.lang.Double> dblFilterToSet(double[] doubles,
java.util.function.DoublePredicate predicate)
doubles - An array of doubles to be filtered.predicate - A predicate with which to filter the doubles array.public static double[] dblFilterDistinct(double[] doubles,
java.util.function.DoublePredicate predicate)
double values (according
to Double.compare(double, double)).doubles - An array of doubles to be filtered.predicate - A predicate with which to filter the doubles array.public static <C extends java.util.Collection<java.lang.Double>> C dblFilter(double[] doubles,
org.perro.functions.predicate.DoubleFilterCollector<C> filterCollector)
dblFilterAndThen(DoublePredicate, Collector) method, which allows you to specify both a
predicate and a Collector to build any type of Collection as a result. For
example:
double[] doubles = ...
List<Double> = DblFilterUtils.dblFilter(doubles, FilterUtils.dblFilterAndThen(DblPredicateUtils.dblGt(1.0D), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
dblFilter(doubles, dblFilterAndThen(dblGt(1.0D), toCollection(LinkedList::new)));
C - The type of the resulting Collection.doubles - An array of doubles to be filtered.filterCollector - An object containing a predicate with which to filter the doubles array, and a Collector
to accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Double>> C dblFilterDistinct(double[] doubles,
org.perro.functions.predicate.DoubleFilterCollector<C> filterCollector)
double values. This
overload takes an object that is built using the dblFilterAndThen(DoublePredicate, Collector) method,
which allows you to specify both a DoublePredicate and a Collector to build any type of
Collection as a result. For example:
double[] doubles = ...
List<Double> = DblFilterUtils.dblFilter(doubles, DblFilterUtils.dblFilterAndThen(DblPredicateUtils.dblGt(1.0D), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
List<Double> = dblFilter(doubles, dblFilterAndThen(dblGt(1.0D), toCollection(LinkedList::new)));
C - The type of the resulting Collection.doubles - An array of doubles to be filtered.filterCollector - An object containing a predicate with which to filter the doubles array, and a Collector
to accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Double>> org.perro.functions.predicate.DoubleFilterCollector<C> dblFilterAndThen(java.util.function.DoublePredicate filter,
java.util.stream.Collector<java.lang.Double,?,C> collector)
DoublePredicate and a Collector for use in the dblFilter(double[], DoubleFilterCollector) method.C - The type of the resulting collection.filter - A Predicate for filtering elements from an array of doubles.collector - A Collector to accumulate elements into a Collection of Double objects.