com.aliasi.util
Class Pair<A,B>

java.lang.Object
  extended by com.aliasi.util.Pair<A,B>

public class Pair<A,B>
extends Object

The Pair class represents an immutable pair of objects of heterogeneous type. This class is useful as a return type for functions computing more than one object.

Identity conditions are that the elements are the same.

Since:
LingPipe3.5
Version:
3.5
Author:
Bob Carpenter

Constructor Summary
Pair(A a, B b)
          Construct a pair consisting of the two specified elements.
 
Method Summary
 A a()
          Return the first value of the pair.
 B b()
          Return the second value of the pair.
 boolean equals(Object that)
          Returns true if the specified object is a pair that has objects equal to this pair's.
 int hashCode()
          Returns the hash code of the pair.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pair

public Pair(A a,
            B b)
Construct a pair consisting of the two specified elements.

Parameters:
a - First element of the pair.
b - Second element of the pair.
Method Detail

a

public A a()
Return the first value of the pair.

Returns:
The first value of the pair.

b

public B b()
Return the second value of the pair.

Returns:
The second value of the pair.

equals

public boolean equals(Object that)
Returns true if the specified object is a pair that has objects equal to this pair's.

Warning: The generic type specifications of the objects being compared do not need to match as long as the elements match.

Overrides:
equals in class Object
Parameters:
that - Object to compare to this pair.
Returns:
true if the specified object is a pair that has objects equal to this pair's.

hashCode

public int hashCode()
Returns the hash code of the pair. The hash code is defined to be consistent with equality:
 hashCode() = 31 * a().hashCode() + b().hashCode();

Overrides:
hashCode in class Object