Package elki.utilities.pairs
Class Pair<F,S>
- java.lang.Object
-
- elki.utilities.pairs.Pair<F,S>
-
- Type Parameters:
F
- first typeS
- second type
- Direct Known Subclasses:
SpatialPair
public class Pair<F,S> extends java.lang.Object
Simple class wrapping two objects.Do not use this for primitive types such as
Integer
andDouble
- avoid the memory waste and garbage collection overhead!Does not implement any "special" interfaces such as Comparable. If you need more complicated pairs, please use domain specific code, with more meaningful field names and comparators.
- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Simple equals statement.F
getFirst()
Getter for firstS
getSecond()
Getter for second element in pairint
hashCode()
Canonical hash function, mixing the two hash values.void
setFirst(F first)
Setter for firstvoid
setSecond(S second)
Setter for secondjava.lang.String
toString()
Canonical toString operator
-
-
-
Method Detail
-
toString
public java.lang.String toString()
Canonical toString operator- Overrides:
toString
in classjava.lang.Object
-
getFirst
public final F getFirst()
Getter for first- Returns:
- first element in pair
-
setFirst
public final void setFirst(F first)
Setter for first- Parameters:
first
- new value for first element
-
getSecond
public final S getSecond()
Getter for second element in pair- Returns:
- second element in pair
-
setSecond
public final void setSecond(S second)
Setter for second- Parameters:
second
- new value for second element
-
equals
public boolean equals(java.lang.Object obj)
Simple equals statement.This Pair equals another Object if they are identical or if the other Object is also a Pair and the
first
andsecond
element of this Pair equal thefirst
andsecond
element, respectively, of the other Pair.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Object to compare to
-
hashCode
public final int hashCode()
Canonical hash function, mixing the two hash values.- Overrides:
hashCode
in classjava.lang.Object
-
-