|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectinfo.javelot.functionalj.tuple.Tuples
public final class Tuples
Contains static methods to zip and unzip tuples. These are:
Zipping consists of creating a list of tuples from a number of collections, creating each tuple by taking corresponding elements from the collections. For example:
zip([1,2,3,4],[5,6,7,8],[9,10,11,12])
returns
[(1,5,9),(2,6,10),(3,7,11),(4,8,12)]
where each element in the resulting list is a Triple.
Unzipping consists of returning a tuple of collections from a collection
of tuples, thus reversing the zipping operation. Unzipping the result of the
previous example would return a Triple containing the original
collections.
| Method Summary | ||
|---|---|---|
static
|
unzipPairs(Collection<Pair<A,B>> p_coll)
Unzips a collection of Pairs into a Pair of lists, with the
first list containing all of the first elements of the pairs, and the second
list containing all of the second elements of the pairs. |
|
static
|
unzipPairs(Pair<A,B>... p_pairs)
Unzips an array of Pairs into a Pair of lists, similarily to
the unzipPairs(Collection) method. |
|
static
|
unzipQuadruples(Collection<Quadruple<A,B,C,D>> p_coll)
Unzips a collection of Quadruples into a Quadruple of
lists, similarily to the unzipPairs(Collection) method. |
|
static
|
unzipQuadruples(Quadruple<A,B,C,D>... p_quadruples)
Unzips an array of Quadruples into a Quadruple of lists,
similarily to the unzipPairs(Collection) method. |
|
static
|
unzipTriples(Collection<Triple<A,B,C>> p_coll)
Unzips a collection of Triples into a Triple of lists,
similarily to the unzipPairs(Collection) method. |
|
static
|
unzipTriples(Triple<A,B,C>... p_triples)
Unzips an array of Triples into a Triple of lists, similarily
to the unzipPairs(Collection) method. |
|
static
|
zip(A[] p_array1,
B[] p_array2)
Zips objects from the two arrays to return a list of Pairs, similarily
to the zip(Collection, Collection) method. |
|
static
|
zip(A[] p_array1,
B[] p_array2,
C[] p_array3)
Zips objects from the three arrays to return a list of Triples,
similarily to the zip(Collection, Collection) method. |
|
static
|
zip(A[] p_array1,
B[] p_array2,
C[] p_array3,
D[] p_array4)
Zips objects from the four arrays to return a list of Quadruples,
similarily to the zip(Collection, Collection) method. |
|
static
|
zip(Collection<A> p_coll1,
Collection<B> p_coll2)
Zips objects from the two collections to return a list of Pairs. |
|
static
|
zip(Collection<A> p_coll1,
Collection<B> p_coll2,
Collection<C> p_coll3)
Zips objects from the three collections to return a list of Triples,
similarily to the zip(Collection, Collection) method. |
|
static
|
zip(Collection<A> p_coll1,
Collection<B> p_coll2,
Collection<C> p_coll3,
Collection<D> p_coll4)
Zips objects from the four collections to return a list of Quadruples,
similarily to the zip(Collection, Collection) method. |
|
static
|
zipWith(Function2<R,P1,P2> p_function2,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2)
Zips objects from the collections to return a list of objects returned by the specified function. |
|
static
|
zipWith(Function2<R,P1,P2> p_function2,
P1[] p_array1,
P2[] p_array2)
Zips objects from the two arrays to return a list of objects returned by the specified function. |
|
static
|
zipWith(Function3<R,P1,P2,P3> p_function3,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2,
Collection<? extends P3> p_coll3)
Zips objects from the three collections to return a list of objects returned by the specified function. |
|
static
|
zipWith(Function3<R,P1,P2,P3> p_function3,
P1[] p_array1,
P2[] p_array2,
P3[] p_array3)
Zips objects from the three arrays to return a list of objects returned by the specified function. |
|
static
|
zipWith(Function4<R,P1,P2,P3,P4> p_function4,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2,
Collection<? extends P3> p_coll3,
Collection<? extends P4> p_coll4)
Zips objects from the four collections to return a list of objects returned by the specified function. |
|
static
|
zipWith(Function4<R,P1,P2,P3,P4> p_function4,
P1[] p_array1,
P2[] p_array2,
P3[] p_array3,
P4[] p_array4)
Zips objects from the four arrays to return a list of objects returned by the specified function. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <A,B> List<Pair<A,B>> zip(Collection<A> p_coll1,
Collection<B> p_coll2)
Pairs.
This method calls zipWith(Function2, Collection, Collection), passing
the Pair.pair function and the two collections. If the collections
contain an unequal number of objects, the number of Pairs returned is
equal to the number of objects contained in the smaller of the two
collections.
p_coll1 - the first of the two collections of objects to zip.p_coll2 - the second of the two collections of objects to zip.
Pairs.
public static <A,B,C> List<Triple<A,B,C>> zip(Collection<A> p_coll1,
Collection<B> p_coll2,
Collection<C> p_coll3)
Triples,
similarily to the zip(Collection, Collection) method.
public static <A,B,C,D> List<Quadruple<A,B,C,D>> zip(Collection<A> p_coll1,
Collection<B> p_coll2,
Collection<C> p_coll3,
Collection<D> p_coll4)
Quadruples,
similarily to the zip(Collection, Collection) method.
public static <A,B> List<Pair<A,B>> zip(A[] p_array1,
B[] p_array2)
Pairs, similarily
to the zip(Collection, Collection) method.
public static <A,B,C> List<Triple<A,B,C>> zip(A[] p_array1,
B[] p_array2,
C[] p_array3)
Triples,
similarily to the zip(Collection, Collection) method.
public static <A,B,C,D> List<Quadruple<A,B,C,D>> zip(A[] p_array1,
B[] p_array2,
C[] p_array3,
D[] p_array4)
Quadruples,
similarily to the zip(Collection, Collection) method.
public static <R,P1,P2> List<R> zipWith(Function2<R,P1,P2> p_function2,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2)
p_function2 - the function used to zip the objects.p_coll1 - the list of the first parameters to the function.p_coll2 - the list of the second parameters to the function.
public static <R,P1,P2,P3> List<R> zipWith(Function3<R,P1,P2,P3> p_function3,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2,
Collection<? extends P3> p_coll3)
zipWith(Function2, Collection, Collection)
public static <R,P1,P2,P3,P4> List<R> zipWith(Function4<R,P1,P2,P3,P4> p_function4,
Collection<? extends P1> p_coll1,
Collection<? extends P2> p_coll2,
Collection<? extends P3> p_coll3,
Collection<? extends P4> p_coll4)
zipWith(Function2, Collection, Collection)
public static <R,P1,P2> List<R> zipWith(Function2<R,P1,P2> p_function2,
P1[] p_array1,
P2[] p_array2)
zipWith(Function2, Collection, Collection)
public static <R,P1,P2,P3> List<R> zipWith(Function3<R,P1,P2,P3> p_function3,
P1[] p_array1,
P2[] p_array2,
P3[] p_array3)
zipWith(Function2, Collection, Collection)
public static <R,P1,P2,P3,P4> List<R> zipWith(Function4<R,P1,P2,P3,P4> p_function4,
P1[] p_array1,
P2[] p_array2,
P3[] p_array3,
P4[] p_array4)
zipWith(Function2, Collection, Collection)public static <A,B> Pair<List<A>,List<B>> unzipPairs(Collection<Pair<A,B>> p_coll)
Pairs into a Pair of lists, with the
first list containing all of the first elements of the pairs, and the second
list containing all of the second elements of the pairs.
p_coll - the collection of Pairs to be unzipped.
Pair containing two lists, one of the first elements of the
pairs, and one of the second elements of the pairs.public static <A,B,C> Triple<List<A>,List<B>,List<C>> unzipTriples(Collection<Triple<A,B,C>> p_coll)
Triples into a Triple of lists,
similarily to the unzipPairs(Collection) method.
unzipPairs(Collection)public static <A,B,C,D> Quadruple<List<A>,List<B>,List<C>,List<D>> unzipQuadruples(Collection<Quadruple<A,B,C,D>> p_coll)
Quadruples into a Quadruple of
lists, similarily to the unzipPairs(Collection) method.
unzipPairs(Collection)public static <A,B> Pair<List<A>,List<B>> unzipPairs(Pair<A,B>... p_pairs)
Pairs into a Pair of lists, similarily to
the unzipPairs(Collection) method.
unzipPairs(Collection)public static <A,B,C> Triple<List<A>,List<B>,List<C>> unzipTriples(Triple<A,B,C>... p_triples)
Triples into a Triple of lists, similarily
to the unzipPairs(Collection) method.
unzipPairs(Collection)public static <A,B,C,D> Quadruple<List<A>,List<B>,List<C>,List<D>> unzipQuadruples(Quadruple<A,B,C,D>... p_quadruples)
Quadruples into a Quadruple of lists,
similarily to the unzipPairs(Collection) method.
unzipPairs(Collection)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||