Package org.jgrapht.alg.util
Class Pair<A,B>
- java.lang.Object
-
- org.jgrapht.alg.util.Pair<A,B>
-
- Type Parameters:
A- the first element typeB- the second element type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
UnorderedPair
public class Pair<A,B> extends Object implements Serializable
Generic pair.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(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.StringtoString()
-
-
-
Method Detail
-
getFirst
public A getFirst()
Get the first element of the pair- Returns:
- the first element of the pair
-
getSecond
public B getSecond()
Get the second element of the pair- Returns:
- the second element of the pair
-
setFirst
public void setFirst(A f)
Set the first element of the pair.- Parameters:
f- the element to be assigned.
-
setSecond
public void setSecond(B s)
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
-
of
public static <A,B> Pair<A,B> of(A a, B b)
Create a new pair.- Type Parameters:
A- the first element typeB- the second element type- Parameters:
a- first elementb- second element- Returns:
- new pair
-
-