T1
- the type of the first elementT2
- the type of the second elementpublic class Pair<T1 extends java.lang.Comparable<? super T1>,T2 extends java.lang.Comparable<? super T2>> extends java.lang.Object implements java.lang.Comparable<Pair<T1,T2>>
Constructor and Description |
---|
Pair(T1 first,
T2 second)
Creates a new Pair.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Pair<T1,T2> o)
Compares the pair to another pair with priority given to the first object.
|
boolean |
equals(java.lang.Object obj)
Returns whether this pair is equal to the given object.
|
T1 |
getFirst()
Returns the first element of the pair.
|
T2 |
getSecond()
Returns the second element of the pair.
|
int |
hashCode()
Hashes this pair using the hashes of both its elements.
|
java.lang.String |
toString()
Returns a string representation of the pair as the string representations of the pair`s
elements separated by a comma in parenthesis.
|
public T1 getFirst()
public T2 getSecond()
public int compareTo(Pair<T1,T2> o)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
Pair
. Pairs are compared using the equals
method to compare both
members of each pair.equals
in class java.lang.Object
obj
- the object to compare this pair topublic int hashCode()
hashCode
in class java.lang.Object