inf.util
Class Pair<C1,C2>

java.lang.Object
  extended by inf.util.Pair<C1,C2>
Type Parameters:
C1 - the type of the first component of this pair
C2 - the type of the second component of this pair

public class Pair<C1,C2>
extends java.lang.Object

This class represents a typed, ordered pair of two Objects. Both components of a Pair may be null. Access to the components is provided through direct access to the public instance variables.

Author:
Gerhard Wickler

Field Summary
 C1 comp1
          the first component of this pair
 C2 comp2
          the second component of this pair
 
Constructor Summary
Pair(C1 comp1, C2 comp2)
           This constructor creates a new Pair that pairs the two given components.
 
Method Summary
 Pair<C1,C2> clone()
           This function creates a semi-shallow clone of this Pair.
 boolean equals(java.lang.Object obj)
           This function tests whether this and the given Object are equal.
 boolean equals(Pair<C1,C2> other)
           This function tests whether this and the given Pair are equal.
 int hashCode()
           This function computes a positive hash value for this pair.
 java.lang.String toString()
           This function returns a printable representation of this Pair.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

comp1

public C1 comp1
the first component of this pair


comp2

public C2 comp2
the second component of this pair

Constructor Detail

Pair

public Pair(C1 comp1,
            C2 comp2)

This constructor creates a new Pair that pairs the two given components. Access to the components is provided through direct access to the public instance variables.

Parameters:
comp1 - the first component of this pair
comp2 - the second component of this pair
Method Detail

clone

public Pair<C1,C2> clone()

This function creates a semi-shallow clone of this Pair. The clone will contain the same components as the original pair. The result is an equal Pair (see equals(Pair)), but not the same (this) Pair.

Overrides:
clone in class java.lang.Object
Returns:
a semi-shallow copy of this Pair

equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given Object are equal. They are equal if the given Object is a Pair that is equal to this Pair. The latter is tested using the equals(Pair) function. The given Object should not be null.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object this should be compared to
Returns:
true if and only if the respective components of the two Pairs are equal

equals

public boolean equals(Pair<C1,C2> other)

This function tests whether this and the given Pair are equal. They are equal if both pairs contain equal components. Note that the given Pair must not be null. However, the components may both be null.

Parameters:
other - the Pair this should be compared to
Returns:
true if and only if the respective components of the two Pairs are equal

hashCode

public int hashCode()

This function computes a positive hash value for this pair. The returned value normally is the sum of the hash values of the two components.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash value for this Pair

toString

public java.lang.String toString()

This function returns a printable representation of this Pair. The general syntax of this string is as follows: <comp1, comp2>.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this Pair