| Constructor and Description |
|---|
Pair(C1 e1,
C2 e2)
Creates a pair from the two specified elements.
|
| Modifier and Type | Method and Description |
|---|---|
static <O> java.lang.Iterable<Pair<O,O>> |
allPairs(java.util.List<? extends O> l)
Returns the list of pairs of elements in the specified list,
excluding the identical pairs and the reversed pairs.
|
int |
compareTo(Pair<C1,C2> pair)
Compares this pair to the specified object.
|
boolean |
equals(java.lang.Object o)
Indicates whether the specified object equals this pair.
|
C1 |
first()
Access to the first element of this pair.
|
int |
hashCode()
Returns a hashcode for this pair.
|
static int |
hashCode(java.lang.Object e1,
java.lang.Object e2)
Returns the hash code value of the specified pair of elements.
|
static <C1,C2> Pair<C1,C2> |
newPair(C1 e1,
C2 e2)
Static constructor.
|
C2 |
second()
Access to the second element of this pair.
|
void |
setFirst(C1 e)
Changes the first element of the pair.
|
void |
setSecond(C2 e)
Changes the second element of the pair.
|
java.lang.String |
toString()
Returns a string representation of this pair.
|
public static <C1,C2> Pair<C1,C2> newPair(C1 e1, C2 e2)
C1 - the type of the first element.C2 - the type of the second element.e1 - the first element of the pair.e2 - the second element of the pair.public int hashCode()
hashcode() method of each object each time it is called.hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to compare to this pair.true if o equals this.public int compareTo(Pair<C1,C2> pair)
compareTo in interface java.lang.Comparable<Pair<C1,C2>>pair - the object to compare to this.java.lang.ClassCastException - if o is not a pair, or if the
objects of the pair cannot be compared, or if their comparison throws an
exception.public C1 first()
public C2 second()
public void setFirst(C1 e)
e - the new first element.public void setSecond(C2 e)
e - the new second element.public java.lang.String toString()
toString in class java.lang.Objectpublic static int hashCode(java.lang.Object e1,
java.lang.Object e2)
p - the pair.p.hashCode()public static <O> java.lang.Iterable<Pair<O,O>> allPairs(java.util.List<? extends O> l)
[a,b,c,d],
the method returns [[a,b],[a,c],[a,d],[b,c],[b,d],[c,d]].l - a list of objects.l.