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.
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.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Pair<K, V> create
(K k, V v) Convenience factory method that calls theconstructor
.boolean
Compare the specified object with this entry for equality.getFirst()
Get the first element of the pair.getKey()
Get the key.Get the second element of the pair.getValue()
Get the value.int
hashCode()
Compute a hash code.toString()
-
Constructor Details
-
Pair
Create an entry representing a mapping from the specified key to the specified value.- Parameters:
k
- Key (first element of the pair).v
- Value (second element of the pair).
-
Pair
Create an entry representing the same mapping as the specified entry.- Parameters:
entry
- Entry to copy.
-
-
Method Details
-
getKey
Get the key.- Returns:
- the key (first element of the pair).
-
getValue
Get the value.- Returns:
- the value (second element of the pair).
-
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.
-
equals
Compare the specified object with this entry for equality. -
hashCode
public int hashCode()Compute a hash code. -
toString
-
create
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
.
-