org.planx.util
Class Pairs

java.lang.Object
  extended by org.planx.util.Pairs

public final class Pairs
extends Object

Utility class that provides methods for easy manipulation of Lists of Pairs.

Author:
Thomas Ambus

Method Summary
static
<E> List<Pair<E,E>>
identityPairs(E[] values)
          Returns a List of Pairs where the two components the ith element return the value of the ith element of values.
static
<E> List<Pair<E,E>>
identityPairs(List<? extends E> values)
          Returns a List of Pairs where the two components the ith element return the value of the ith element of values.
static
<E,F> List<Pair<E,F>>
mergePairs(E[] labels, F[] values)
          Returns a List of Pairs where the first component of the ith element returns the value of the ith element of labels and the second component of the ith element returns the value of the ith element of values.
static
<E,F> List<Pair<E,F>>
mergePairs(List<? extends E> labels, List<? extends F> values)
          Returns a List of Pairs where the first component of the ith element returns the value of the ith element of labels and the second component of the ith element returns the value of the ith element of values.
static
<E,F> List<E>
retainFirst(List<? extends Pair<? extends E,? extends F>> pairs)
          Returns a List containing only the first components of the specified List of Pairs.
static
<E,F> List<F>
retainSecond(List<? extends Pair<? extends E,? extends F>> pairs)
          Returns a List containing only the second components of the specified List of Pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

identityPairs

public static <E> List<Pair<E,E>> identityPairs(E[] values)
Returns a List of Pairs where the two components the ith element return the value of the ith element of values.


identityPairs

public static <E> List<Pair<E,E>> identityPairs(List<? extends E> values)
Returns a List of Pairs where the two components the ith element return the value of the ith element of values.


mergePairs

public static <E,F> List<Pair<E,F>> mergePairs(E[] labels,
                                               F[] values)
Returns a List of Pairs where the first component of the ith element returns the value of the ith element of labels and the second component of the ith element returns the value of the ith element of values. The two arguments must be of equal size.


mergePairs

public static <E,F> List<Pair<E,F>> mergePairs(List<? extends E> labels,
                                               List<? extends F> values)
Returns a List of Pairs where the first component of the ith element returns the value of the ith element of labels and the second component of the ith element returns the value of the ith element of values. The two arguments must be of equal size.


retainFirst

public static <E,F> List<E> retainFirst(List<? extends Pair<? extends E,? extends F>> pairs)
Returns a List containing only the first components of the specified List of Pairs.


retainSecond

public static <E,F> List<F> retainSecond(List<? extends Pair<? extends E,? extends F>> pairs)
Returns a List containing only the second components of the specified List of Pairs.



Copyright © 2010. All Rights Reserved.