public final class LongFilterUtils
extends java.lang.Object
long 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.Long>> |
longFilter(long[] longs,
org.perro.functions.predicate.LongFilterCollector<C> filterCollector)
Filters an array of
long primitives, based a predicate, into a Collection. |
static long[] |
longFilter(long[] longs,
java.util.function.LongPredicate predicate)
Filters an array of
long primitives, based a predicate, into another long array. |
static <C extends java.util.Collection<java.lang.Long>> |
longFilterAndThen(java.util.function.LongPredicate filter,
java.util.stream.Collector<java.lang.Long,?,C> collector)
Builds an object combining a
LongPredicate and a Collector for use in the longFilter(long[], LongFilterCollector) method. |
static <C extends java.util.Collection<java.lang.Long>> |
longFilterDistinct(long[] longs,
org.perro.functions.predicate.LongFilterCollector<C> filterCollector)
Filters an array of longs, based a predicate, into an array of distinct
long values. |
static long[] |
longFilterDistinct(long[] longs,
java.util.function.LongPredicate predicate)
Filters an array of longs, based a predicate, into an array of distinct
long values (according
to Long.compare(long, long)). |
static java.util.Set<java.lang.Long> |
longFilterToSet(long[] longs,
java.util.function.LongPredicate predicate)
Filters an array of
long primitives, based a predicate, into a Set. |
public static long[] longFilter(long[] longs,
java.util.function.LongPredicate predicate)
long primitives, based a predicate, into another long array.longs - An array of longs to be filtered.predicate - A predicate with which to filter the longs array.public static java.util.Set<java.lang.Long> longFilterToSet(long[] longs,
java.util.function.LongPredicate predicate)
long primitives, based a predicate, into a Set.longs - An array of longs to be filtered.predicate - A predicate with which to filter the longs array.public static long[] longFilterDistinct(long[] longs,
java.util.function.LongPredicate predicate)
long values (according
to Long.compare(long, long)).longs - An array of longs to be filtered.predicate - A predicate with which to filter the longs array.public static <C extends java.util.Collection<java.lang.Long>> C longFilter(long[] longs,
org.perro.functions.predicate.LongFilterCollector<C> filterCollector)
long primitives, based a predicate, into a Collection. This overload takes an
object that is built using the longFilterAndThen(LongPredicate, Collector) method, which allows you to
specify both a predicate and a Collector to build any type of Collection
as a result. For example:
long[] longs = ...
List<Long> = LongFilterUtils.longFilter(longs, FilterUtils.longFilterAndThen(LongPredicateUtils.longGt(1.0D), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
longFilter(longs, longFilterAndThen(longGt(1.0D), toCollection(LinkedList::new)));
C - The type of the resulting Collection.longs - An array of longs to be filtered.filterCollector - An object containing a predicate with which to filter the longs array, and a Collector to
accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Long>> C longFilterDistinct(long[] longs,
org.perro.functions.predicate.LongFilterCollector<C> filterCollector)
long values. This overload
takes an object that is built using the longFilterAndThen(LongPredicate, Collector) method, which allows
you to specify both a LongPredicate and a Collector to build any type of
Collection as a result. For example:
long[] longs = ...
List<Long> = LongFilterUtils.longFilter(longs, LongFilterUtils.longFilterAndThen(LongPredicateUtils.longGt(1L), Collectors.toCollection(LinkedList::new)));
Or, with static imports:
List<Long> = longFilter(longs, longFilterAndThen(longGt(1L), toCollection(LinkedList::new)));
C - The type of the resulting Collection.longs - An array of longs to be filtered.filterCollector - An object containing a predicate with which to filter the longs array, and a Collector to
accumulate results into a Collection.public static <C extends java.util.Collection<java.lang.Long>> org.perro.functions.predicate.LongFilterCollector<C> longFilterAndThen(java.util.function.LongPredicate filter,
java.util.stream.Collector<java.lang.Long,?,C> collector)
LongPredicate and a Collector for use in the longFilter(long[], LongFilterCollector) method.C - The type of the resulting collection.filter - A Predicate for filtering elements from an array of longs.collector - A Collector to accumulate elements into a Collection of Long objects.