Class NaturalRanking.DataPosition

java.lang.Object
org.apache.commons.statistics.ranking.NaturalRanking.DataPosition
All Implemented Interfaces:
Comparable<NaturalRanking.DataPosition>
Enclosing class:
NaturalRanking

private static class NaturalRanking.DataPosition extends Object implements Comparable<NaturalRanking.DataPosition>
Represents the position of a double value in a data array. The Comparable interface is implemented so Arrays.sort can be used to sort an array of data positions by value. Note that the implicitly defined natural ordering is NOT consistent with equals.
  • Field Details

    • value

      private final double value
      Data value.
    • position

      private final int position
      Data position.
  • Constructor Details

    • DataPosition

      DataPosition(double value, int position)
      Create an instance with the given value and position.
      Parameters:
      value - Data value.
      position - Data position.
  • Method Details

    • compareTo

      public int compareTo(NaturalRanking.DataPosition other)
      Compare this value to another. Only the values are compared.
      Specified by:
      compareTo in interface Comparable<NaturalRanking.DataPosition>
      Parameters:
      other - the other pair to compare this to
      Returns:
      result of Double.compare(value, other.value)
    • getPosition

      int getPosition()
      Returns the data position.
      Returns:
      position