Package dev.majek.pc.util
Class Pair<A,B>
- java.lang.Object
-
- dev.majek.pc.util.Pair<A,B>
-
- Type Parameters:
A- the first type.B- the second type.
public final class Pair<A,B> extends Object
Stores two related values. This data structure is very useful if an object must be passed with a property that is not part of that object. This class is based off of the C++ structstd::pair.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)AgetFirst()Get the first value in the pair.BgetSecond()Get the second value in the pair.inthashCode()Creates a hash code for this object.voidsetFirst(A newValue)Set the first value in the pair to the specified value.voidsetSecond(B newValue)Set the second value in the pair to the specified value.StringtoString()
-
-
-
Constructor Detail
-
Pair
public Pair(A first, B second)
Constructs a new instance ofPairwith the two values stored in the pair.- Parameters:
first- the first value.second- the second value.
-
Pair
public Pair()
Constructs a new instance ofPairwithout specifying the two values stored in the pair.
-
-
Method Detail
-
getFirst
public A getFirst()
Get the first value in the pair.- Returns:
- the first value in the pair.
-
setFirst
public void setFirst(A newValue)
Set the first value in the pair to the specified value.- Parameters:
newValue- the new first value.
-
getSecond
public B getSecond()
Get the second value in the pair.- Returns:
- the second value in the pair.
-
setSecond
public void setSecond(B newValue)
Set the second value in the pair to the specified value.- Parameters:
newValue- the new second value.
-
hashCode
public int hashCode()
Creates a hash code for this object.
-
-