Package elki.utilities.pairs
Class DoubleDoublePair
- java.lang.Object
-
- elki.utilities.pairs.DoubleDoublePair
-
- All Implemented Interfaces:
java.lang.Comparable<DoubleDoublePair>
public class DoubleDoublePair extends java.lang.Object implements java.lang.Comparable<DoubleDoublePair>
Pair storing two doubles.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<DoubleDoublePair>
BYFIRST_COMPARATOR
Comparator to compare by second component onlystatic java.util.Comparator<DoubleDoublePair>
BYSECOND_COMPARATOR
Comparator to compare by second component onlydouble
first
first valuedouble
second
second valuestatic java.util.Comparator<DoubleDoublePair>
SWAPPED_COMPARATOR
Comparator to compare by swapped components
-
Constructor Summary
Constructors Constructor Description DoubleDoublePair(double first, double second)
ConstructorDoubleDoublePair(DoubleDoublePair other)
Clone constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareSwappedTo(DoubleDoublePair other)
Implementation of comparableSwapped interface, sorting by second then first.int
compareTo(DoubleDoublePair other)
Implementation of comparable interface, sorting by first then second.boolean
equals(java.lang.Object obj)
Trivial equals implementationint
hashCode()
Trivial hashCode implementation mixing the two integers.void
setFirst(double first)
Set first valuevoid
setSecond(double second)
Set second valuejava.lang.String
toString()
-
-
-
Field Detail
-
first
public double first
first value
-
second
public double second
second value
-
BYFIRST_COMPARATOR
public static final java.util.Comparator<DoubleDoublePair> BYFIRST_COMPARATOR
Comparator to compare by second component only
-
BYSECOND_COMPARATOR
public static final java.util.Comparator<DoubleDoublePair> BYSECOND_COMPARATOR
Comparator to compare by second component only
-
SWAPPED_COMPARATOR
public static final java.util.Comparator<DoubleDoublePair> SWAPPED_COMPARATOR
Comparator to compare by swapped components
-
-
Constructor Detail
-
DoubleDoublePair
public DoubleDoublePair(double first, double second)
Constructor- Parameters:
first
- First valuesecond
- Second value
-
DoubleDoublePair
public DoubleDoublePair(DoubleDoublePair other)
Clone constructor.- Parameters:
other
- Existing pair.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Trivial equals implementation- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Object to compare to
-
hashCode
public final int hashCode()
Trivial hashCode implementation mixing the two integers.- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(DoubleDoublePair other)
Implementation of comparable interface, sorting by first then second.- Specified by:
compareTo
in interfacejava.lang.Comparable<DoubleDoublePair>
- Parameters:
other
- Object to compare to- Returns:
- comparison result
-
compareSwappedTo
public int compareSwappedTo(DoubleDoublePair 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(double second)
Set second value- Parameters:
second
- new value
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-