Package elki.utilities.pairs
Class DoubleIntPair
- java.lang.Object
-
- elki.utilities.pairs.DoubleIntPair
-
- All Implemented Interfaces:
java.lang.Comparable<DoubleIntPair>
public class DoubleIntPair extends java.lang.Object implements java.lang.Comparable<DoubleIntPair>
Pair storing an integer and a double.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<DoubleIntPair>BYFIRST_COMPARATORComparator to compare by first component onlystatic java.util.Comparator<DoubleIntPair>BYSECOND_COMPARATORComparator to compare by second component onlydoublefirstfirst valueintsecondsecond valuestatic java.util.Comparator<DoubleIntPair>SWAPPED_COMPARATORComparator to compare by swapped components
-
Constructor Summary
Constructors Constructor Description DoubleIntPair(double first, int second)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareSwappedTo(DoubleIntPair other)Implementation of comparableSwapped interface, sorting by second then first.intcompareTo(DoubleIntPair other)Implementation of comparable interface, sorting by first then second.booleanequals(java.lang.Object obj)Trivial equals implementationinthashCode()Trivial hashCode implementation mixing the two integers.voidsetFirst(double first)Set first valuevoidsetSecond(int second)Set second value
-
-
-
Field Detail
-
first
public double first
first value
-
second
public int second
second value
-
BYFIRST_COMPARATOR
public static final java.util.Comparator<DoubleIntPair> BYFIRST_COMPARATOR
Comparator to compare by first component only
-
BYSECOND_COMPARATOR
public static final java.util.Comparator<DoubleIntPair> BYSECOND_COMPARATOR
Comparator to compare by second component only
-
SWAPPED_COMPARATOR
public static final java.util.Comparator<DoubleIntPair> SWAPPED_COMPARATOR
Comparator to compare by swapped components
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Trivial equals implementation- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- Object to compare to
-
hashCode
public final int hashCode()
Trivial hashCode implementation mixing the two integers.- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(DoubleIntPair other)
Implementation of comparable interface, sorting by first then second.- Specified by:
compareToin interfacejava.lang.Comparable<DoubleIntPair>- Parameters:
other- Object to compare to- Returns:
- comparison result
-
compareSwappedTo
public int compareSwappedTo(DoubleIntPair other)
Implementation of comparableSwapped interface, sorting by second then first.- Parameters:
other- Object to compare to- Returns:
- comparison result
-
setFirst
public final void setFirst(double first)
Set first value- Parameters:
first- new value
-
setSecond
public final void setSecond(int second)
Set second value- Parameters:
second- new value
-
-