public final class IntTransformUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> int[] |
flatMapToInt(java.util.Collection<T> objects,
java.util.function.Function<T,int[]> function)
Given a collection of objects of type <T>, and a
Function<T, int[]>, returns an array
of primitive ints. |
static <T> int[] |
flatMapToIntDistinct(java.util.Collection<T> objects,
java.util.function.Function<T,int[]> function)
Given a collection of objects of type <T>, and a
Function<T, int[]>, returns an array of
distinct primitive ints. |
static int[] |
intFlatMap(int[] ints,
java.util.function.IntFunction<int[]> function)
Given an array of ints, and an
IntFunction<int[]> (a function that takes an int and returns an
array of ints), returns an array of ints. |
static int[] |
intFlatMapDistinct(int[] ints,
java.util.function.IntFunction<int[]> function)
Given an array of ints, and an
IntFunction<int[]> (a function that takes an int and returns an
array of ints), returns an array of distinct primitive int values. |
static <C extends java.util.Collection<java.lang.Integer>> |
intTransform(int[] ints,
java.util.stream.Collector<java.lang.Integer,?,C> collector)
Given an array of ints, and a
Collector<Integer, ?, C>, returns a
Collection<C> of Integer elements. |
static <R> java.util.List<R> |
intTransform(int[] ints,
java.util.function.IntFunction<R> transformer)
Given an array of ints, and an
IntFunction<R> that transforms those ints into elements of type
<R>, returns a List<R> of those elements. |
static <U,C extends java.util.Collection<U>> |
intTransform(int[] ints,
org.perro.functions.mapper.IntTransformerCollector<U,C> transformerCollector)
Given an array of ints, and an
IntTransformerCollector<U, C> that contains an
IntFunction<U> to transform int 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>> |
intTransformAndThen(java.util.function.IntFunction<U> transformer,
java.util.stream.Collector<U,?,C> collector)
Builds an
IntTransformerCollector<U, C> that contains an IntFunction<U> to
transform primitive int 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> |
intTransformDistinct(int[] ints,
java.util.function.IntFunction<R> transformer)
Given an array of ints, and an
IntFunction<R> that transforms those ints 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> |
intTransformToMap(int[] ints,
org.perro.functions.mapper.IntKeyValueMapper<K,V> keyValueMapper)
Given an array of primitive ints, and an
IntKeyValueMapper containing an IntFunction to
transform an int to a key of type <K>, and another IntFunction to transform an int to a value
of type <V>, returns a Map<K, V>. |
static <R> java.util.Set<R> |
intTransformToSet(int[] ints,
java.util.function.IntFunction<R> transformer)
Given an array of ints, and an
IntFunction<R> that transforms those ints into elements of type
<R>, returns a Set<R> of those elements. |
static int[] |
intUnaryTransform(int[] ints,
java.util.function.IntUnaryOperator operator)
Given an array of ints, and an
IntUnaryOperator that transforms each of those ints to another int,
returns an array of the resulting int values. |
static int[] |
intUnaryTransformDistinct(int[] ints,
java.util.function.IntUnaryOperator operator)
Given an array of ints, and an
IntUnaryOperator that transforms each of those ints to another
int, returns an array of the resulting int values, which will contain only distinct values. |
public static int[] intUnaryTransform(int[] ints,
java.util.function.IntUnaryOperator operator)
IntUnaryOperator that transforms each of those ints to another int,
returns an array of the resulting int values.ints - An array of ints to be transformed.operator - An IntUnaryOperator that takes an int and transforms it to another int.public static int[] intUnaryTransformDistinct(int[] ints,
java.util.function.IntUnaryOperator operator)
IntUnaryOperator that transforms each of those ints to another
int, returns an array of the resulting int values, which will contain only distinct values.ints - An array of ints to be transformed.operator - An IntUnaryOperator that takes an int and transforms it to another int.public static <R> java.util.List<R> intTransform(int[] ints,
java.util.function.IntFunction<R> transformer)
IntFunction<R> that transforms those ints into elements of type
<R>, returns a List<R> of those elements.R - The type of the elements in the resulting List.ints - An array of ints to be transformed.transformer - An IntFunction<R> that takes an int and transforms it to an element of type <R>.public static <R> java.util.Set<R> intTransformToSet(int[] ints,
java.util.function.IntFunction<R> transformer)
IntFunction<R> that transforms those ints into elements of type
<R>, returns a Set<R> of those elements.R - The type of the elements in the resulting Set.ints - An array of ints to be transformed.transformer - An IntFunction<R> that takes an int and transforms it to an element of type <R>.public static <C extends java.util.Collection<java.lang.Integer>> C intTransform(int[] ints,
java.util.stream.Collector<java.lang.Integer,?,C> collector)
Collector<Integer, ?, C>, returns a
Collection<C> of Integer elements.C - The type of the collection of Integer values returned.ints - An array of ints to be collected.collector - A Collector<Integer, ?, C> that appends Integer values into a collection of type
<C>.public static <R> java.util.List<R> intTransformDistinct(int[] ints,
java.util.function.IntFunction<R> transformer)
IntFunction<R> that transforms those ints 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.ints - An array of ints to be transformed.transformer - An IntFunction<R> that takes an int and transforms it to an element of type <R>.public static <U,C extends java.util.Collection<U>> C intTransform(int[] ints,
org.perro.functions.mapper.IntTransformerCollector<U,C> transformerCollector)
IntTransformerCollector<U, C> that contains an
IntFunction<U> to transform int 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
intTransformAndThen(IntFunction, Collector).U - The type of the elements in the resulting Collection.C - The type of the Collection of elements of type <U> returned.ints - An array of ints to be transformed.transformerCollector - A object containing a transformer IntFunction<U> to transform int values into
elements of type <U>, and a Collector<U, ?, C> to put those elements into
a resulting collection.public static int[] intFlatMap(int[] ints,
java.util.function.IntFunction<int[]> function)
IntFunction<int[]> (a function that takes an int and returns an
array of ints), returns an array of ints.ints - An array of primitive ints to be flat-mapped into another array of ints.function - An IntFunction that takes an int and returns an array of ints.public static int[] intFlatMapDistinct(int[] ints,
java.util.function.IntFunction<int[]> function)
IntFunction<int[]> (a function that takes an int and returns an
array of ints), returns an array of distinct primitive int values.ints - An array of primitive ints to be flat-mapped into another array of ints.function - An IntFunction that takes an int and returns an array of ints.public static <T> int[] flatMapToInt(java.util.Collection<T> objects,
java.util.function.Function<T,int[]> function)
Function<T, int[]>, returns an array
of primitive ints.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 ints.function - A Function that takes an element of type <T> and returns a primitive int array.public static <T> int[] flatMapToIntDistinct(java.util.Collection<T> objects,
java.util.function.Function<T,int[]> function)
Function<T, int[]>, returns an array of
distinct primitive ints.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 ints.function - A Function that takes an element of type <T> and returns a primitive int array.public static <U,C extends java.util.Collection<U>> org.perro.functions.mapper.IntTransformerCollector<U,C> intTransformAndThen(java.util.function.IntFunction<U> transformer,
java.util.stream.Collector<U,?,C> collector)
IntTransformerCollector<U, C> that contains an IntFunction<U> to
transform primitive int 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
intTransform(int[], IntTransformerCollector).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 - An IntFunction<U> to transform primitive int values into elements of type
<U>.collector - A Collector<U, ?, C> to append elements into a collection of type <C>.IntFunction<U> to transform primitive int 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> intTransformToMap(int[] ints,
org.perro.functions.mapper.IntKeyValueMapper<K,V> keyValueMapper)
IntKeyValueMapper containing an IntFunction to
transform an int to a key of type <K>, and another IntFunction to transform an int 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>.ints - An array of primitive ints to be transformed into keys and values for the resulting
Map<K, V>.keyValueMapper - An object containing an IntFunction to transform an int to a key of type <K>,
and another IntFunction to transform an int to a value of type <V>.