info.javelot.functionalj.tuple
Class Tuples

java.lang.Object
  extended byinfo.javelot.functionalj.tuple.Tuples

public final class Tuples
extends Object

Contains static methods to operate on tuples.

Author:
Copyright © 2006 Frederic Daoud

Method Summary
static Pair unzipPairs(List p_list)
          Unzips a list 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 Pair unzipPairs(Pair[] p_pairs)
          Unzips an array of Pairs into a Pair of lists, similarily to the unzipPairs(List) method.
static Quadruple unzipQuadruples(List p_list)
          Unzips a list of Quadruples into a Quadruple of lists, similarily to the unzipPairs(List) method.
static Quadruple unzipQuadruples(Quadruple[] p_quadruples)
          Unzips an array of Quadruples into a Quadruple of lists, similarily to the unzipPairs(List) method.
static Triple unzipTriples(List p_list)
          Unzips a list of Triples into a Triple of lists, similarily to the unzipPairs(List) method.
static Triple unzipTriples(Triple[] p_triples)
          Unzips an array of Triples into a Triple of lists, similarily to the unzipPairs(List) method.
static List zip(List p_list1, List p_list2)
          Zips objects from the two lists to return a list of Pairs.
static List zip(List p_list1, List p_list2, List p_list3)
          Zips objects from the three lists to return a list of Triples, similarily to the zip(List,List) method.
static List zip(List p_list1, List p_list2, List p_list3, List p_list4)
          Zips objects from the four lists to return a list of Quadruples, similarily to the zip(List,List) method.
static List zip(Object[] p_array1, Object[] p_array2)
          Zips objects from the two arrays to return a list of Pairs, similarily to the zip(List,List) method.
static List zip(Object[] p_array1, Object[] p_array2, Object[] p_array3)
          Zips objects from the three arrays to return a list of Triples, similarily to the zip(List,List) method.
static List zip(Object[] p_array1, Object[] p_array2, Object[] p_array3, Object[] p_array4)
          Zips objects from the four arrays to return a list of Quadruples, similarily to the zip(List,List) method.
static List zipWith(Function p_function, List[] p_lists)
          Zips objects from the lists to return a list of objects returned by the specified function.
static List zipWith(Function p_function, List p_list1, List p_list2)
          Zips objects from the two lists to return a list of objects returned by the specified function.
static List zipWith(Function p_function, List p_list1, List p_list2, List p_list3)
          Zips objects from the three lists to return a list of objects returned by the specified function.
static List zipWith(Function p_function, List p_list1, List p_list2, List p_list3, List p_list4)
          Zips objects from the four lists to return a list of objects returned by the specified function.
static List zipWith(Function p_function, Object[] p_array1, Object[] p_array2)
          Zips objects from the two arrays to return a list of objects returned by the specified function.
static List zipWith(Function p_function, Object[] p_array1, Object[] p_array2, Object[] p_array3)
          Zips objects from the three arrays to return a list of objects returned by the specified function.
static List zipWith(Function p_function, Object[] p_array1, Object[] p_array2, Object[] p_array3, Object[] 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

zip

public static List zip(List p_list1,
                       List p_list2)
Zips objects from the two lists to return a list of Pairs. This method calls zipWith(Function,List,List), passing the Pair.Pair(Object,Object) constructor function and the two lists. If the lists 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 lists.

Parameters:
p_list1 - the first of the two lists of objects to zip.
p_list2 - the second of the two lists of objects to zip.
Returns:
a list of Pairs.

zip

public static List zip(List p_list1,
                       List p_list2,
                       List p_list3)
Zips objects from the three lists to return a list of Triples, similarily to the zip(List,List) method.


zip

public static List zip(List p_list1,
                       List p_list2,
                       List p_list3,
                       List p_list4)
Zips objects from the four lists to return a list of Quadruples, similarily to the zip(List,List) method.


zip

public static List zip(Object[] p_array1,
                       Object[] p_array2)
Zips objects from the two arrays to return a list of Pairs, similarily to the zip(List,List) method.


zip

public static List zip(Object[] p_array1,
                       Object[] p_array2,
                       Object[] p_array3)
Zips objects from the three arrays to return a list of Triples, similarily to the zip(List,List) method.


zip

public static List zip(Object[] p_array1,
                       Object[] p_array2,
                       Object[] p_array3,
                       Object[] p_array4)
Zips objects from the four arrays to return a list of Quadruples, similarily to the zip(List,List) method.


zipWith

public static List zipWith(Function p_function,
                           List p_list1,
                           List p_list2)
Zips objects from the two lists to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           Object[] p_array1,
                           Object[] p_array2)
Zips objects from the two arrays to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           List p_list1,
                           List p_list2,
                           List p_list3)
Zips objects from the three lists to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           Object[] p_array1,
                           Object[] p_array2,
                           Object[] p_array3)
Zips objects from the three arrays to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           List p_list1,
                           List p_list2,
                           List p_list3,
                           List p_list4)
Zips objects from the four lists to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           Object[] p_array1,
                           Object[] p_array2,
                           Object[] p_array3,
                           Object[] p_array4)
Zips objects from the four arrays to return a list of objects returned by the specified function. See zipWith(Function,List[]) method for more details.

See Also:
zipWith(Function,List[])

zipWith

public static List zipWith(Function p_function,
                           List[] p_lists)
Zips objects from the lists to return a list of objects returned by the specified function. The function must either accept as many parameters as there are lists, or be an InstanceFunction for which the object has not been specified, and that accepts one less parameter than there are lists. The function is called using corresponding objects from the lists, and a list of results is returned. If the lists are not of the same size, the size of the smallest list is used. Thus objects of the lists that exceed the size of the smallest list are not used.

Parameters:
p_function - the function which is called to zip the objects from the lists.
p_lists - the lists of objects to zip.
Returns:
a list of results of calling the function with the objects from the lists.

unzipPairs

public static Pair unzipPairs(List p_list)
Unzips a list 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.

Parameters:
p_list - the list of Pairs to be unzipped.
Returns:
a Pair containing two lists, one of the first elements of the pairs, and one of the second elements of the pairs.

unzipPairs

public static Pair unzipPairs(Pair[] p_pairs)
Unzips an array of Pairs into a Pair of lists, similarily to the unzipPairs(List) method.

See Also:
unzipPairs(List)

unzipTriples

public static Triple unzipTriples(List p_list)
Unzips a list of Triples into a Triple of lists, similarily to the unzipPairs(List) method.

See Also:
unzipPairs(List)

unzipTriples

public static Triple unzipTriples(Triple[] p_triples)
Unzips an array of Triples into a Triple of lists, similarily to the unzipPairs(List) method.

See Also:
unzipPairs(List)

unzipQuadruples

public static Quadruple unzipQuadruples(List p_list)
Unzips a list of Quadruples into a Quadruple of lists, similarily to the unzipPairs(List) method.

See Also:
unzipPairs(List)

unzipQuadruples

public static Quadruple unzipQuadruples(Quadruple[] p_quadruples)
Unzips an array of Quadruples into a Quadruple of lists, similarily to the unzipPairs(List) method.

See Also:
unzipPairs(List)