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 boolean
equals(Object object)
A
getFirst()
Get the first value in the pair.B
getSecond()
Get the second value in the pair.int
hashCode()
Creates a hash code for this object.void
setFirst(A newValue)
Set the first value in the pair to the specified value.void
setSecond(B newValue)
Set the second value in the pair to the specified value.String
toString()
-
-
-
Constructor Detail
-
Pair
public Pair(A first, B second)
Constructs a new instance ofPair
with the two values stored in the pair.- Parameters:
first
- the first value.second
- the second value.
-
Pair
public Pair()
Constructs a new instance ofPair
without 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.
-
-