Class NaturalRanking.DataPosition

  • All Implemented Interfaces:
    java.lang.Comparable<NaturalRanking.DataPosition>
    Enclosing class:
    NaturalRanking

    private static class NaturalRanking.DataPosition
    extends java.lang.Object
    implements java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private int position
      Data position.
      private double value
      Data value.
    • Constructor Summary

      Constructors 
      Constructor Description
      DataPosition​(double value, int position)
      Create an instance with the given value and position.
    • Field Detail

      • value

        private final double value
        Data value.
      • position

        private final int position
        Data position.
    • Constructor Detail

      • DataPosition

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

      • compareTo

        public int compareTo​(NaturalRanking.DataPosition other)
        Compare this value to another. Only the values are compared.
        Specified by:
        compareTo in interface java.lang.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