java.lang.Object
org.jgrapht.alg.util.Pair<A,B>
- Type Parameters:
A- the first element typeB- the second element type
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
UnorderedPair
public class Pair<A,B>
extends java.lang.Object
implements java.io.Serializable
Generic pair.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)AgetFirst()Get the first element of the pairBgetSecond()Get the second element of the pair<E> booleanhasElement(E e)Assess if this pair contains an element.inthashCode()static <A, B> Pair<A,B>of(A a, B b)Create a new pair.voidsetFirst(A f)Set the first element of the pair.voidsetSecond(B s)Set the second element of the pair.java.lang.StringtoString()
-
Field Details
-
Constructor Details
-
Pair
Create a new pair- Parameters:
a- the first elementb- the second element
-
-
Method Details
-
getFirst
Get the first element of the pair- Returns:
- the first element of the pair
-
getSecond
Get the second element of the pair- Returns:
- the second element of the pair
-
setFirst
Set the first element of the pair.- Parameters:
f- the element to be assigned.
-
setSecond
Set the second element of the pair.- Parameters:
s- the element to be assigned.
-
hasElement
public <E> boolean hasElement(E e)Assess if this pair contains an element.- Type Parameters:
E- the element type- Parameters:
e- The element in question- Returns:
- true if contains the element, false otherwise
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
of
Create a new pair.- Type Parameters:
A- the first element typeB- the second element type- Parameters:
a- first elementb- second element- Returns:
- new pair
-