public class OrderedTuple extends Object implements Comparable<OrderedTuple>
Ordering is done by encoding all components of the T-uple into a single scalar value and using this value as the
sorting key. Encoding is performed using the method invented by Georg Cantor in 1877 when he proved it was possible
to establish a bijection between a line and a plane. The binary representations of the components of the T-uple are
mixed together to form a single scalar. This means that the 2k bit of component 0 is followed by the
2k bit of component 1, then by the 2k bit of component 2 up to the 2k bit of
component t
, which is followed by the 2k-1 bit of component 0, followed by the 2k-1 bit
of component 1 ... The binary representations are extended as needed to handle numbers with different scales and a
suitable 2p offset is added to the components in order to avoid negative numbers (this offset is adjusted
as needed during the comparison operations).
The more interesting property of the encoding method for our purpose is that it allows to select all the points that are in a given range. This is depicted in dimension 2 by the following picture:
T-uples with negative infinite or positive infinite components are sorted logically.
Since the specification of the Comparator
interface allows only ClassCastException
errors, some
arbitrary choices have been made to handle specific cases. The rationale for these choices is to keep
regular and consistent T-uples together.
Double.NaN
components are sorted after all other ones (even after instances with positive
infinite componentsDouble.NaN
componentsConstructor and Description |
---|
OrderedTuple(double... componentsIn)
Build an ordered T-uple from its components.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(OrderedTuple ot)
Compares this ordered T-uple with the specified object.
|
boolean |
equals(Object other) |
double[] |
getComponents()
Get the components array.
|
int |
hashCode() |
public OrderedTuple(double... componentsIn)
componentsIn
- double components of the T-uplepublic int compareTo(OrderedTuple ot)
The ordering method is detailed in the general description of the class. Its main property is to be consistent with distance: geometrically close T-uples stay close to each other when stored in a sorted collection using this comparison method.
T-uples with negative infinite, positive infinite are sorted logically.
Some arbitrary choices have been made to handle specific cases. The rationale for these choices is to keep normal and consistent T-uples together.
Double.NaN
components are sorted after all other ones (evan after instances with
positive infinite componentsDouble.NaN
componentscompareTo
in interface Comparable<OrderedTuple>
ot
- T-uple to compare instance withpublic double[] getComponents()
Copyright © 2020 CNES. All rights reserved.