Package org.hipparchus.util
Class Pair<K,V>
- java.lang.Object
-
- org.hipparchus.util.Pair<K,V>
-
- Type Parameters:
K
- Key type.V
- Value type.
- Direct Known Subclasses:
PointValuePair
,PointVectorValuePair
public class Pair<K,V> extends Object
Generic pair.Although the instances of this class are immutable, it is impossible to ensure that the references passed to the constructor will not be modified by the caller.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
Pair<K,V>create(K k, V v)
Convenience factory method that calls theconstructor
.boolean
equals(Object o)
Compare the specified object with this entry for equality.K
getFirst()
Get the first element of the pair.K
getKey()
Get the key.V
getSecond()
Get the second element of the pair.V
getValue()
Get the value.int
hashCode()
Compute a hash code.String
toString()
-
-
-
Method Detail
-
getKey
public K getKey()
Get the key.- Returns:
- the key (first element of the pair).
-
getValue
public V getValue()
Get the value.- Returns:
- the value (second element of the pair).
-
getFirst
public K getFirst()
Get the first element of the pair.- Returns:
- the first element of the pair.
-
getSecond
public V getSecond()
Get the second element of the pair.- Returns:
- the second element of the pair.
-
equals
public boolean equals(Object o)
Compare the specified object with this entry for equality.
-
hashCode
public int hashCode()
Compute a hash code.
-
create
public static <K,V> Pair<K,V> create(K k, V v)
Convenience factory method that calls theconstructor
.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k
- First element of the pair.v
- Second element of the pair.- Returns:
- a new
Pair
containingk
andv
.
-
-