|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.tuple.Tuples
public class Tuples
Class methods hub for creating AbstractTuples, and obtaining
Tuple-related functions
| Constructor Summary | |
|---|---|
Tuples()
|
|
| Method Summary | ||
|---|---|---|
static
|
_(T1 first,
T2 second)
Creates a new Tuple2 |
|
static
|
_(T1 first,
T2 second,
T3 third)
Creates a new Tuple3 |
|
static
|
_(T1 first,
T2 second,
T3 third,
T4 fourth)
Creates a new Quadruple |
|
static
|
branch(net.sf.staccatocommons.defs.Applicable<? super A,? extends B> function0,
net.sf.staccatocommons.defs.Applicable<? super A,? extends C> function1)
Answers a function that applies both given functions to its argument, and returns both results, as a Pair. |
|
static
|
clone(net.sf.staccatocommons.defs.Applicable<? super A,? extends B> function0)
Answers a function that returns a Tuple2 that contains the original function argument and the result of applying +------function0-----> >----+ +--------------------> |
|
static
|
curry(net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>,C> function)
Curries the given function that takes a single Tuple2, by returning a new one
that takes two arguments, one for each component of the pair |
|
static
|
curry(net.sf.staccatocommons.defs.predicate.Predicate<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>> predicate)
Curries the given predicate that takes a single Tuple2, by returning a new
one that takes two arguments, one for each component of the pair |
|
static
|
curry3(net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>,D> function)
Curries the given function that takes a single Tuple3, by returning a new one
that takes three arguments, one for each component of the triple |
|
static
|
first()
Answers a function that returns the first component of a tuple |
|
static
|
fourth()
Answers a function that returns the fourth component of a tuple |
|
static
|
merge(net.sf.staccatocommons.defs.Applicable<? super B,? extends C> function)
|
|
static
|
second()
Answers a function that returns the second component of a tuple |
|
static
|
third()
Answers a function that returns the third component of a tuple |
|
static
|
toTuple2()
Answers a function that creates Tuple2s for its arguments |
|
static
|
toTuple3()
Answers a function that creates Tuple3s for its arguments |
|
static
|
zip(net.sf.staccatocommons.defs.Applicable<? super A,? extends C> function0,
net.sf.staccatocommons.defs.Applicable<? super B,? extends D> function1)
Combines two functions into one that takes a pair and applies the first function to the first component, and the second function to the second component, and returns the pair of results. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Tuples()
| Method Detail |
|---|
@Constant public static <A> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.partial.FirstAware<A>,A> first()
A - type of the first element
@Constant public static <A> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.partial.SecondAware<A>,A> second()
A - type of the second element
@Constant public static <A> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.partial.ThirdAware<A>,A> third()
A - type of the third element
@Constant public static <A> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.partial.FourthAware<A>,A> fourth()
A - type of the fourth element
@NonNull
public static <T1,T2,T3,T4> net.sf.staccatocommons.defs.tuple.Tuple4<T1,T2,T3,T4> _(T1 first,
T2 second,
T3 third,
T4 fourth)
Quadruple
T1 - T2 - T3 - T4 - first - second - third - fourth -
Quadruple. Non null.
@NonNull
public static <T1,T2,T3> net.sf.staccatocommons.defs.tuple.Tuple3<T1,T2,T3> _(T1 first,
T2 second,
T3 third)
Tuple3
T1 - T2 - T3 - first - second - third -
Tuple3. Non null.
@NonNull
public static <T1,T2> net.sf.staccatocommons.defs.tuple.Tuple2<T1,T2> _(T1 first,
T2 second)
Tuple2
T1 - T2 - first - second -
Tuple2. Non null.@Constant public static <T1,T2,T3> net.sf.staccatocommons.defs.function.Function3<T1,T2,T3,net.sf.staccatocommons.defs.tuple.Tuple3<T1,T2,T3>> toTuple3()
Tuple3s for its arguments
T1 - T2 -
Function3@Constant public static <T1,T2> net.sf.staccatocommons.defs.function.Function2<T1,T2,net.sf.staccatocommons.defs.tuple.Tuple2<T1,T2>> toTuple2()
Tuple2s for its arguments
T1 - T2 - T3 -
Function2public static <A,B,C> net.sf.staccatocommons.defs.function.Function2<A,B,C> curry(net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>,C> function)
function that takes a single Tuple2, by returning a new one
that takes two arguments, one for each component of the pair
A - B - C - function - the function to curry
Function2public static <A,B,C,D> net.sf.staccatocommons.defs.function.Function3<A,B,C,D> curry3(net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple3<A,B,C>,D> function)
function that takes a single Tuple3, by returning a new one
that takes three arguments, one for each component of the triple
A - B - C - function - the function to curry
Function3public static <A,B> net.sf.staccatocommons.defs.predicate.Predicate2<A,B> curry(net.sf.staccatocommons.defs.predicate.Predicate<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>> predicate)
predicate that takes a single Tuple2, by returning a new
one that takes two arguments, one for each component of the pair
A - B - C - predicate - the function to curry
Predicate2
public static <A,B,C,D> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>,net.sf.staccatocommons.defs.tuple.Tuple2<C,D>> zip(net.sf.staccatocommons.defs.Applicable<? super A,? extends C> function0,
net.sf.staccatocommons.defs.Applicable<? super B,? extends D> function1)
>------function0-----> >------function1----->Example:
zip(NumberTypes.add(10), NumberTypes.add(1)).apply(_(2,0))Returns the tuple
(12, 1)
function0 - function1 -
public static <A,B,C> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.tuple.Tuple2<A,B>,C> merge(net.sf.staccatocommons.defs.Applicable<? super B,? extends C> function)
public static <A,B,C> net.sf.staccatocommons.defs.function.Function<A,net.sf.staccatocommons.defs.tuple.Tuple2<B,C>> branch(net.sf.staccatocommons.defs.Applicable<? super A,? extends B> function0,
net.sf.staccatocommons.defs.Applicable<? super A,? extends C> function1)
Pair.
Functions get combined as in the following figure:
+------function0----->
>----+
+------function1----->
Example:
branch(NumberTypes.add(10), Compare.greaterThan(5)).apply(2)Returns the tuple
(12, false)
A - B - C - function0 - the function whose result will be the first component of the tuplefunction1 - the function whose result will be the second component of the
tuple
Function that "branches" its argumentpublic static <A,B> net.sf.staccatocommons.defs.function.Function<A,net.sf.staccatocommons.defs.tuple.Tuple2<A,B>> clone(net.sf.staccatocommons.defs.Applicable<? super A,? extends B> function0)
+------function0----->
>----+
+-------------------->
A - B - function0 -
Function
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||