fr.ens_cachan.dptinfo.util
Class Pair<F extends java.lang.Comparable<? super F>,S extends java.lang.Comparable<? super S>>

java.lang.Object
  extended by fr.ens_cachan.dptinfo.util.Pair<F,S>
All Implemented Interfaces:
java.lang.Comparable<Pair<F,S>>

public class Pair<F extends java.lang.Comparable<? super F>,S extends java.lang.Comparable<? super S>>
extends java.lang.Object
implements java.lang.Comparable<Pair<F,S>>

A generic implementation of a pair of elements. Pairs are restricted to hold Comparable elements.

See Also:
Comparable

Constructor Summary
Pair(F f, S s)
          Creates a new pair.
 
Method Summary
 int compareTo(Pair<F,S> o)
          Compares this pair with the specified pair for order, using the order on the first element, and the order on the second element in case of equality on the first one.
 boolean equals(java.lang.Object obj)
          Indicates whether this Pair is equivalent to the passed Object.
 F getFirst()
          Return the first element in this pair.
 S getSecond()
          Return the second element in this pair.
 int hashCode()
          Return a hash code value for this pair.
 void setFirst(F f)
          Sets the first element in this pair.
 void setSecond(S s)
          Sets the second element in this pair.
 java.lang.String toString()
          Return a String representation of this pair.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(F f,
            S s)
Creates a new pair.

Parameters:
f - the first element of the pair.
s - the second element of the pair.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Indicates whether this Pair is equivalent to the passed Object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - an Object to be tested for equivalence.
Returns:
true if and only if obj is a Pair and both its first and second elements are equivalent to this pair's first and second elements.

compareTo

public int compareTo(Pair<F,S> o)
Compares this pair with the specified pair for order, using the order on the first element, and the order on the second element in case of equality on the first one.

Specified by:
compareTo in interface java.lang.Comparable<Pair<F extends java.lang.Comparable<? super F>,S extends java.lang.Comparable<? super S>>>
Parameters:
o - another Pair with comparable types.
Returns:
a negative integer, zero, or a positive integer as this pair is less than, equal to, or greater than o.

getFirst

public F getFirst()
Return the first element in this pair.

Returns:
fst

getSecond

public S getSecond()
Return the second element in this pair.

Returns:
snd

hashCode

public int hashCode()
Return a hash code value for this pair. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code based on the hashes of the two elements in this pair.

setFirst

public void setFirst(F f)
Sets the first element in this pair.

Parameters:
f - the new value for the first element.

setSecond

public void setSecond(S s)
Sets the second element in this pair.

Parameters:
s - the new value for the second element.

toString

public java.lang.String toString()
Return a String representation of this pair.

Overrides:
toString in class java.lang.Object
Returns:
the String representations of the two elements between angle brackets.