java.lang.Object
de.lmu.ifi.dbs.elki.utilities.pairs.DoubleIntPair
- All Implemented Interfaces:
PairInterface<Double,
,Integer> Comparable<DoubleIntPair>
public class DoubleIntPair
extends Object
implements Comparable<DoubleIntPair>, PairInterface<Double,Integer>
Pair storing an integer and a double.
Since double and int are native types, this can't be done via the
CPair
generic.- Author:
- Erich Schubert
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<DoubleIntPair>
Comparator to compare by first component onlystatic final Comparator<DoubleIntPair>
Comparator to compare by second component onlydouble
first valueint
second valuestatic final Comparator<DoubleIntPair>
Comparator to compare by swapped components -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compareSwappedTo
(DoubleIntPair other) Implementation of comparableSwapped interface, sorting by second then first.int
compareTo
(DoubleIntPair other) Implementation of comparable interface, sorting by first then second.boolean
Trivial equals implementationfinal Double
getFirst()
Deprecated.use pair.first to avoid boxing!final Integer
Deprecated.use pair.first to avoid boxing!final int
hashCode()
Trivial hashCode implementation mixing the two integers.final void
setFirst
(double first) Set first valuefinal void
setSecond
(int second) Set second value
-
Field Details
-
first
public double firstfirst value -
second
public int secondsecond value -
BYFIRST_COMPARATOR
Comparator to compare by first component only -
BYSECOND_COMPARATOR
Comparator to compare by second component only -
SWAPPED_COMPARATOR
Comparator to compare by swapped components
-
-
Constructor Details
-
DoubleIntPair
public DoubleIntPair(double first, int second) Constructor- Parameters:
first
- First valuesecond
- Second value
-
-
Method Details
-
equals
Trivial equals implementation -
hashCode
public final int hashCode()Trivial hashCode implementation mixing the two integers. -
compareTo
Implementation of comparable interface, sorting by first then second.- Specified by:
compareTo
in interfaceComparable<DoubleIntPair>
- Parameters:
other
- Object to compare to- Returns:
- comparison result
-
compareSwappedTo
Implementation of comparableSwapped interface, sorting by second then first.- Parameters:
other
- Object to compare to- Returns:
- comparison result
-
getFirst
Deprecated.use pair.first to avoid boxing!Description copied from interface:PairInterface
Get the first object - note: this may cause autoboxing, use pair.first for native pairs!- Specified by:
getFirst
in interfacePairInterface<Double,
Integer> - Returns:
- First object
-
setFirst
public final void setFirst(double first) Set first value- Parameters:
first
- new value
-
getSecond
Deprecated.use pair.first to avoid boxing!Description copied from interface:PairInterface
Get the second object - note: this may cause autoboxing, use pair.second for native pairs!- Specified by:
getSecond
in interfacePairInterface<Double,
Integer> - Returns:
- Second object
-
setSecond
public final void setSecond(int second) Set second value- Parameters:
second
- new value
-