org.eigenbase.util
Class Pair<T1,T2>

java.lang.Object
  extended by org.eigenbase.util.Pair<T1,T2>

public class Pair<T1,T2>
extends Object

Pair of objects.

Since:
Oct 17, 2007
Version:
$Id: //open/dev/farrago/src/org/eigenbase/util/Pair.java#4 $
Author:
jhyde

Field Summary
 T1 left
           
 T2 right
           
 
Constructor Summary
Pair(T1 left, T2 right)
          Creates a Pair.
 
Method Summary
 boolean equals(Object obj)
           
 int hashCode()
           
static
<K,V> Map<K,V>
toMap(Collection<Pair<K,V>> pairs)
          Converts a collection of Pairs into a Map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

left

public final T1 left

right

public final T2 right
Constructor Detail

Pair

public Pair(T1 left,
            T2 right)
Creates a Pair.

Parameters:
left - left value
right - right value
Method Detail

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toMap

public static <K,V> Map<K,V> toMap(Collection<Pair<K,V>> pairs)
Converts a collection of Pairs into a Map.

This is an obvious thing to do because Pair is similar in structure to Map.Entry.

The map contains a copy of the collection of Pairs; if you change the collection, the map does not change.

Parameters:
pairs - Collection of Pair objects
Returns:
map with the same contents as the collection