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.ObjectSimple class wrapping two objects.Do not use this for primitive types such as
IntegerandDouble- 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 booleanequals(java.lang.Object obj)Simple equals statement.FgetFirst()Getter for firstSgetSecond()Getter for second element in pairinthashCode()Canonical hash function, mixing the two hash values.voidsetFirst(F first)Setter for firstvoidsetSecond(S second)Setter for secondjava.lang.StringtoString()Canonical toString operator
-
-
-
Method Detail
-
toString
public java.lang.String toString()
Canonical toString operator- Overrides:
toStringin 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
firstandsecondelement of this Pair equal thefirstandsecondelement, respectively, of the other Pair.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- Object to compare to
-
hashCode
public final int hashCode()
Canonical hash function, mixing the two hash values.- Overrides:
hashCodein classjava.lang.Object
-
-