public final class LongTransformUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> long[] |
flatMapToLong(java.util.Collection<T> objects,
java.util.function.Function<T,long[]> function)
Given a collection of objects of type <T>, and a
Function<T, long[]>, returns an array
of primitive longs. |
static <T> long[] |
flatMapToLongDistinct(java.util.Collection<T> objects,
java.util.function.Function<T,long[]> function)
Given a collection of objects of type <T>, and a
Function<T, long[]>, returns an array
of distinct primitive longs. |
static long[] |
longFlatMap(long[] longs,
java.util.function.LongFunction<long[]> function)
Given an array of longs, and a
LongFunction<int[]> (a function that takes a long and returns
an array of longs), returns an array of longs. |
static long[] |
longFlatMapDistinct(long[] longs,
java.util.function.LongFunction<long[]> function)
Given an array of longs, and a
LongFunction<long[]> (a function that takes a long and returns
an array of longs), returns an array of distinct primitive long values. |
static <C extends java.util.Collection<java.lang.Long>> |
longTransform(long[] longs,
java.util.stream.Collector<java.lang.Long,?,C> collector)
Given an array of longs, and a
Collector<Long, ?, C>, returns a
Collection<C> of Long elements. |
static <R> java.util.List<R> |
longTransform(long[] longs,
java.util.function.LongFunction<R> transformer)
Given an array of longs, and a
LongFunction<R> that transforms those longs into elements of
type <R>, returns a List<R> of those elements. |
static <U,C extends java.util.Collection<U>> |
longTransform(long[] longs,
org.perro.functions.mapper.LongTransformerCollector<U,C> transformerCollector)
Given an array of longs, and a
LongTransformerCollector<U, C> that contains a
LongFunction<U> to transform long values into elements of type <U>, and a
Collector<U, ?, C>, returns a collection of type <C> of those elements. |
static <U,C extends java.util.Collection<U>> |
longTransformAndThen(java.util.function.LongFunction<U> transformer,
java.util.stream.Collector<U,?,C> collector)
Builds a
LongTransformerCollector<U, C> that contains a LongFunction<U> to
transform primitive long values into elements of type <U>, and a Collector<U, ?, C> to
collect those elements into a collection of type <C>. |
static <R> java.util.List<R> |
longTransformDistinct(long[] longs,
java.util.function.LongFunction<R> transformer)
Given an array of longs, and a
LongFunction<R> that transforms those longs into elements of
type <R>, returns a List<R> of those elements, which will contain only unique values
(according to Object.equals(Object)). |
static <K,V> java.util.Map<K,V> |
longTransformToMap(long[] longs,
org.perro.functions.mapper.LongKeyValueMapper<K,V> keyValueMapper)
Given an array of primitive longs, and a
LongKeyValueMapper containing a LongFunction
to transform a long to a key of type <K>, and another LongFunction to transform a long to a
value of type <V>, returns a Map<K, V>. |
static <R> java.util.Set<R> |
longTransformToSet(long[] longs,
java.util.function.LongFunction<R> transformer)
Given an array of longs, and a
LongFunction<R> that transforms those longs into elements of
type <R>, returns a Set<R> of those elements. |
static long[] |
longUnaryTransform(long[] longs,
java.util.function.LongUnaryOperator operator)
Given an array of longs, and a
LongUnaryOperator that transforms each of those longs to another long,
returns an array of the resulting long values. |
static long[] |
longUnaryTransformDistinct(long[] longs,
java.util.function.LongUnaryOperator operator)
Given an array of longs, and a
LongUnaryOperator that transforms each of those longs to another
long, returns an array of the resulting long values, which will contain only distinct values. |
public static long[] longUnaryTransform(long[] longs,
java.util.function.LongUnaryOperator operator)
LongUnaryOperator that transforms each of those longs to another long,
returns an array of the resulting long values.longs - An array of ints to be transformed.operator - A LongUnaryOperator that takes a long and transforms it to another long.public static long[] longUnaryTransformDistinct(long[] longs,
java.util.function.LongUnaryOperator operator)
LongUnaryOperator that transforms each of those longs to another
long, returns an array of the resulting long values, which will contain only distinct values.longs - An array of ints to be transformed.operator - A LongUnaryOperator that takes a long and transforms it to another long.public static <R> java.util.List<R> longTransform(long[] longs,
java.util.function.LongFunction<R> transformer)
LongFunction<R> that transforms those longs into elements of
type <R>, returns a List<R> of those elements.R - The type of the elements in the resulting List.longs - An array of longs to be transformed.transformer - A LongFunction<R> that takes a long and transforms it to an element of type <R>.public static <R> java.util.Set<R> longTransformToSet(long[] longs,
java.util.function.LongFunction<R> transformer)
LongFunction<R> that transforms those longs into elements of
type <R>, returns a Set<R> of those elements.R - The type of the elements in the resulting Set.longs - An array of longs to be transformed.transformer - A LongFunction<R> that takes a long and transforms it to an element of type <R>.public static <C extends java.util.Collection<java.lang.Long>> C longTransform(long[] longs,
java.util.stream.Collector<java.lang.Long,?,C> collector)
Collector<Long, ?, C>, returns a
Collection<C> of Long elements.C - The type of the collection of Long values returned.longs - An array of longs to be collected.collector - A Collector<Long, ?, C> that appends Long values into a collection of type <C>.public static <R> java.util.List<R> longTransformDistinct(long[] longs,
java.util.function.LongFunction<R> transformer)
LongFunction<R> that transforms those longs into elements of
type <R>, returns a List<R> of those elements, which will contain only unique values
(according to Object.equals(Object)).R - The type of the elements in the resulting List.longs - An array of longs to be transformed.transformer - A LongFunction<R> that takes a long and transforms it to an element of type <R>.public static <U,C extends java.util.Collection<U>> C longTransform(long[] longs,
org.perro.functions.mapper.LongTransformerCollector<U,C> transformerCollector)
LongTransformerCollector<U, C> that contains a
LongFunction<U> to transform long values into elements of type <U>, and a
Collector<U, ?, C>, returns a collection of type <C> of those elements. The
transformerCollection passed into this method should be created via a call to
longTransformAndThen(LongFunction, Collector).U - The type of the elements in the resulting Collection.C - The type of the Collection of elements of type <U> returned.longs - An array of longs to be transformed.transformerCollector - A object containing a transformer LongFunction<U> to transform long values into
elements of type <U>, and a Collector<U, ?, C> to put those elements into
a resulting collection.public static long[] longFlatMap(long[] longs,
java.util.function.LongFunction<long[]> function)
LongFunction<int[]> (a function that takes a long and returns
an array of longs), returns an array of longs.longs - An array of primitive longs to be flat-mapped into another array of longs.function - A LongFunction that takes a long and returns an array of longs.public static long[] longFlatMapDistinct(long[] longs,
java.util.function.LongFunction<long[]> function)
LongFunction<long[]> (a function that takes a long and returns
an array of longs), returns an array of distinct primitive long values.longs - An array of primitive longs to be flat-mapped into another array of longs.function - A LongFunction that takes a long and returns an array of longs.public static <T> long[] flatMapToLong(java.util.Collection<T> objects,
java.util.function.Function<T,long[]> function)
Function<T, long[]>, returns an array
of primitive longs.T - The type of the elements in the given objects collection.objects - A collection of objects of type <T>, to be flat-mapped into an array of primitive longs.function - A Function that takes an element of type <T> and returns a primitive long array.public static <T> long[] flatMapToLongDistinct(java.util.Collection<T> objects,
java.util.function.Function<T,long[]> function)
Function<T, long[]>, returns an array
of distinct primitive longs.T - The type of the elements in the given objects collection.objects - A collection of objects of type <T>, to be flat-mapped into an array of primitive longs.function - A Function that takes an element of type <T> and returns a primitive long array.public static <U,C extends java.util.Collection<U>> org.perro.functions.mapper.LongTransformerCollector<U,C> longTransformAndThen(java.util.function.LongFunction<U> transformer,
java.util.stream.Collector<U,?,C> collector)
LongTransformerCollector<U, C> that contains a LongFunction<U> to
transform primitive long values into elements of type <U>, and a Collector<U, ?, C> to
collect those elements into a collection of type <C>. Used to build the second parameter to
longTransform(long[], LongTransformerCollector).U - The type of the elements into which int values are to be transformed.C - The type of a collection of elements of type <U>, into which a given collector will
append elements.transformer - A LongFunction<U> to transform primitive long values into elements of type
<U>.collector - A Collector<U, ?, C> to append elements into a collection of type <C>.LongFunction<U> to transform primitive long values into
elements of type <U>, and a Collector<U, ?, C> to append those elements into a
collection of type <C>.public static <K,V> java.util.Map<K,V> longTransformToMap(long[] longs,
org.perro.functions.mapper.LongKeyValueMapper<K,V> keyValueMapper)
LongKeyValueMapper containing a LongFunction
to transform a long to a key of type <K>, and another LongFunction to transform a long to a
value of type <V>, returns a Map<K, V>.K - The type of the key of the resulting Map<K, V>.V - The type of the value of the resulting Map<K, V>.longs - An array of primitive longs to be transformed into keys and values for the resulting
Map<K, V>.keyValueMapper - An object containing a LongFunction to transform a long to a key of type <K>,
and another LongFunction to transform a long to a value of type <V>.