public final class DblStreamUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
dblAllMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
Given an array of doubles and a
DoublePredicate, returns a boolean value indicating
whether all of the values in the array match the predicate. |
static boolean |
dblAnyMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
Given an array of doubles and a
DoublePredicate, returns a boolean value indicating
whether any of the values in the array match the predicate. |
static long |
dblCount(double[] doubles,
java.util.function.DoublePredicate predicate)
Given an array of doubles and a
DoublePredicate, returns a long value indicating the
number of values in the array that match the predicate. |
static double |
dblMaxDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
Given an array of doubles, and an object representing a
DoublePredicate along with a default value,
this method returns the maximum double value in the array that matches the predicate, or the default value if no
matching values are found. |
static double |
dblMaxDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
Given an array of doubles, and an object representing a
DoublePredicate along with a
Supplier for a default value, this method returns the maximum double value in the array that matches
the predicate, or a default value from the supplier if no matching values are found. |
static double |
dblMinDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
Given an array of doubles, and an object representing a
DoublePredicate along with a default value,
this method returns the minimum double value in the array that matches the predicate, or the default value if no
matching values are found. |
static double |
dblMinDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
Given an array of doubles, and an object representing a
DoublePredicate along with a
Supplier for a default value, this method returns the minimum double value in the array that matches
the predicate, or a default value from the supplier if no matching values are found. |
static boolean |
dblNoneMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
Given an array of doubles and a
DoublePredicate, returns a boolean value indicating
whether none of the values in the array match the predicate. |
static java.util.stream.DoubleStream |
defaultDblStream(java.util.Collection<java.lang.Double> objects)
Given a
Collection of Double instances, returns a DoubleStream of them. |
static java.util.stream.DoubleStream |
defaultDblStream(double[] array)
Given an array of
double values, returns a DoubleStream of them. |
static java.util.stream.DoubleStream |
defaultDblStream(java.util.stream.DoubleStream stream)
Given a
DoubleStream returns that stream if it is not null, otherwise returns an empty
DoubleStream. |
static java.util.stream.DoubleStream |
defaultDblStream(java.util.stream.Stream<java.lang.Double> stream)
Given a
Stream of Double instances, returns a DoubleStream from it, or an
empty DoubleStream if it is null. |
static double |
findAnyDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
Attempt to find any matching double value in an array of doubles using a predicate, returning a default value if
one is not found.
|
static double |
findAnyDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
Attempt to find any matching double value in an array of doubles using a predicate, returning a default value
retrieved using a
DoubleSupplier if one is not found. |
static java.lang.Double |
findAnyDblDefaultNull(double[] doubles,
java.util.function.DoublePredicate predicate)
Attempt to find any matching double value in an array of doubles using a predicate, returning
null
if one is not found. |
static org.perro.functions.stream.FindDoubleWithDefault |
findDblDefault(java.util.function.DoublePredicate predicate,
double defaultValue)
Retrieves an object representing a predicate for finding a value, and a default double value if one is not found.
|
static org.perro.functions.stream.FindDoubleWithDefaultSupplier |
findDblDefault(java.util.function.DoublePredicate predicate,
java.util.function.DoubleSupplier defaultSupplier)
Retrieves an object representing a predicate for finding a value, and a default
DoubleSupplier if
one is not found. |
static double |
findFirstDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
Attempt to find the first matching double value in an array of doubles using a predicate, returning a default
value if one is not found.
|
static double |
findFirstDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
Attempt to find the first matching double value in an array of doubles using a predicate, returning a default
value retrieved using a
DoubleSupplier if one is not found. |
static java.lang.Double |
findFirstDblDefaultNull(double[] doubles,
java.util.function.DoublePredicate predicate)
Attempt to find the first matching double value in an array of doubles using a predicate, returning
null if one is not found. |
static int |
indexOfFirstDbl(double[] doubles,
java.util.function.DoublePredicate predicate)
Finds the index of the first double in an array that matches a
DoublePredicate. |
static java.util.List<double[]> |
toPartitionedDblList(double[] doubles,
int partitionSize)
Given an array of doubles, and a partition size, this method divides the array into a list of double arrays, each
of whose length is at most
partitionSize. |
static java.util.stream.Stream<double[]> |
toPartitionedDblStream(double[] doubles,
int partitionSize)
Given an array of doubles, and a partition size, this method divides the array into a stream of double arrays,
each of whose length is at most
partitionSize. |
public static boolean dblAllMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
DoublePredicate, returns a boolean value indicating
whether all of the values in the array match the predicate.doubles - An array of doubles to be checked whether the given DoublePredicate matches all of its values.predicate - A DoublePredicate to match against the values in the input array.public static boolean dblAnyMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
DoublePredicate, returns a boolean value indicating
whether any of the values in the array match the predicate.doubles - An array of doubles to be checked whether the given DoublePredicate matches any of its values.predicate - A DoublePredicate to match against the values in the input array.public static boolean dblNoneMatch(double[] doubles,
java.util.function.DoublePredicate predicate)
DoublePredicate, returns a boolean value indicating
whether none of the values in the array match the predicate.doubles - An array of doubles to be checked whether the given DoublePredicate matches none of its values.predicate - A DoublePredicate to match against the values in the input array.public static long dblCount(double[] doubles,
java.util.function.DoublePredicate predicate)
DoublePredicate, returns a long value indicating the
number of values in the array that match the predicate.doubles - An array of doubles to be counted for the number of them that match the given DoublePredicate.predicate - A DoublePredicate to match against the values in the input array.public static double dblMaxDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
DoublePredicate along with a default value,
this method returns the maximum double value in the array that matches the predicate, or the default value if no
matching values are found.doubles - An array of doubles from which to get the maximum value or the default value in the given
findWithDefault object.findWithDefault - An object representing a DoublePredicate along with a default value.public static double dblMaxDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
DoublePredicate along with a
Supplier for a default value, this method returns the maximum double value in the array that matches
the predicate, or a default value from the supplier if no matching values are found.doubles - An array of doubles from which to get the maximum value or the default value from
the supplier in the given findWithDefaultSupplier object.findWithDefaultSupplier - An object representing a DoublePredicate along with a Supplier of a default value.public static double dblMinDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
DoublePredicate along with a default value,
this method returns the minimum double value in the array that matches the predicate, or the default value if no
matching values are found.doubles - An array of doubles from which to get the minimum value or the default value in the given
findWithDefault object.findWithDefault - An object representing a DoublePredicate along with a default value.public static double dblMinDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
DoublePredicate along with a
Supplier for a default value, this method returns the minimum double value in the array that matches
the predicate, or a default value from the supplier if no matching values are found.doubles - An array of doubles from which to get the minimum value or the default value from
the supplier in the given findWithDefaultSupplier object.findWithDefaultSupplier - An object representing a DoublePredicate along with a Supplier of a default value.public static java.lang.Double findAnyDblDefaultNull(double[] doubles,
java.util.function.DoublePredicate predicate)
null
if one is not found. This method does all filtering with a primitive DoubleStream, boxing the stream
and calling Stream.findAny() only after it has been filtered. Here is a contrived example of how
this method would be called:
{
...
return DblStreamUtils.findAnyDblDefaultNull(doubleArray, DblPredicateUtils.isDblEqual(2.0D, Function.identity()));
}
Or, with static imports:
{
...
return findAnyDblDefaultNull(doubleArray, isDblEqual(2.0D, identity()));
}
doubles - An array of primitive double values.predicate - A predicate for finding a Double value.public static double findAnyDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
{
...
return DblStreamUtils.findAnyDblDefault(doubleArray, DblStreamUtils.findDblDefault(DblPredicateUtils.isDblEqual(2.0D, Function.identity()), -1.0D));
}
Or, with static imports:
{
...
return findAnyDblDefault(doubleArray, findDblDefault(isDblEqual(2.0D, identity()), -1.0D));
}
doubles - An array of primitive double values.findWithDefault - An object representing a predicate for finding a value, and a default if one is not found.
Use the findDblDefault(DoublePredicate, double) to provide this parameter.public static double findAnyDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
DoubleSupplier if one is not found. Here is a contrived example of how this method
would be called:
{
...
return DblStreamUtils.findAnyDblDefault(doubleArray, DblStreamUtils.findDblDefault(
DblPredicateUtils.isDblEqual(2.0D, Function.identity()), Double.valueOf(-1.0D)::doubleValue));
}
Or, with static imports:
{
...
return findAnyDblDefault(doubleArray, findDblDefault(isDblEqual(2.0D, identity()), Double.valueOf(-1.0D)::doubleValue));
}
doubles - An array of primitive double values.findWithDefaultSupplier - An object representing a predicate for finding a value, and a default
DoubleSupplier if one is not found. Use the
findDblDefault(DoublePredicate, DoubleSupplier) method to provide
this parameter.public static java.lang.Double findFirstDblDefaultNull(double[] doubles,
java.util.function.DoublePredicate predicate)
null if one is not found. This method does all filtering with a primitive DoubleStream,
boxing the stream and calling Stream.findAny() only after it has been filtered. Here is a contrived
example of how this method would be called:
{
...
return DblStreamUtils.findFirstDblDefaultNull(doubleArray, DblPredicateUtils.isDblEqual(2.0D, Function.identity()));
}
Or, with static imports:
{
...
return findFirstDblDefaultNull(doubleArray, isDblEqual(2.0D, identity()));
}
doubles - An array of primitive double values.predicate - A predicate for finding a Double value.public static double findFirstDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefault findWithDefault)
{
...
return DblStreamUtils.findFirstDblDefault(doubleArray, DblStreamUtils.findDblDefault(DblPredicateUtils.isDblEqual(2.0D, Function.identity()), -1.0D));
}
Or, with static imports:
{
...
return findFirstDblDefault(doubleArray, findDblDefault(isDblEqual(2.0D, identity()), -1.0D));
}
doubles - An array of primitive double values.findWithDefault - An object representing a predicate for finding a value, and a default if one is not found.
Use the findDblDefault(DoublePredicate, double) to provide this parameter.public static double findFirstDblDefault(double[] doubles,
org.perro.functions.stream.FindDoubleWithDefaultSupplier findWithDefaultSupplier)
DoubleSupplier if one is not found. Here is a contrived example of how this
method would be called:
{
...
return DblStreamUtils.findAnyDblDefault(doubleArray, DblStreamUtils.findDblDefault(
DblPredicateUtils.isDblEqual(2.0D, Function.identity()), Double.valueOf(-1.0D)::doubleValue));
}
Or, with static imports:
{
...
return findAnyDblDefault(doubleArray, findDblDefault(isDblEqual(2.0D, identity()), Double.valueOf(-1.0D)::doubleValue));
}
doubles - An array of primitive double values.findWithDefaultSupplier - An object representing a predicate for finding a value, and a default
DoubleSupplier if one is not found. Use the
findDblDefault(DoublePredicate, DoubleSupplier) method to provide
this parameter.public static org.perro.functions.stream.FindDoubleWithDefault findDblDefault(java.util.function.DoublePredicate predicate,
double defaultValue)
findAnyDblDefault(double[], FindDoubleWithDefault) or
findFirstDblDefault(double[], FindDoubleWithDefault) for usage examples.predicate - A predicate used in finding a particular double value.defaultValue - A default double value to return if one could not be found using the above predicate.public static org.perro.functions.stream.FindDoubleWithDefaultSupplier findDblDefault(java.util.function.DoublePredicate predicate,
java.util.function.DoubleSupplier defaultSupplier)
DoubleSupplier if
one is not found. See findAnyDblDefault(double[], FindDoubleWithDefaultSupplier) or
findFirstDblDefault(double[], FindDoubleWithDefaultSupplier) for usage examples.predicate - A predicate used in finding a particular double value.defaultSupplier - A default DoubleSupplier used to return if one could not be found using the above
predicate.public static int indexOfFirstDbl(double[] doubles,
java.util.function.DoublePredicate predicate)
DoublePredicate.doubles - Array of primitive double values.predicate - A DoublePredicate used to find a matching value.public static java.util.List<double[]> toPartitionedDblList(double[] doubles,
int partitionSize)
partitionSize.doubles - An array of doubles to be partitioned up into a list of double arrays.partitionSize - The maximum length of the individual arrays in the returned list.public static java.util.stream.Stream<double[]> toPartitionedDblStream(double[] doubles,
int partitionSize)
partitionSize.doubles - An array of doubles to be partitioned up into a stream of double arrays.partitionSize - The maximum length of the individual arrays in the returned stream.public static java.util.stream.DoubleStream defaultDblStream(double[] array)
double values, returns a DoubleStream of them.array - An array of doubles from which to return a DoubleStream.public static java.util.stream.DoubleStream defaultDblStream(java.util.stream.DoubleStream stream)
DoubleStream returns that stream if it is not null, otherwise returns an empty
DoubleStream.stream - An input DoubleStream.public static java.util.stream.DoubleStream defaultDblStream(java.util.Collection<java.lang.Double> objects)
Collection of Double instances, returns a DoubleStream of them.objects - A Collection of Double instances.public static java.util.stream.DoubleStream defaultDblStream(java.util.stream.Stream<java.lang.Double> stream)
Stream of Double instances, returns a DoubleStream from it, or an
empty DoubleStream if it is null.stream - A Collection of Double instances.