Package ffx.utilities

Record Class DoubleIndexPair

java.lang.Object
java.lang.Record
ffx.utilities.DoubleIndexPair
Record Components:
index - the original index of this double.
doubleValue - the double value.
All Implemented Interfaces:
Comparable<DoubleIndexPair>

public record DoubleIndexPair(int index, double doubleValue) extends Record implements Comparable<DoubleIndexPair>
DoubleIndexPair record.

Allows sorting of floating-point values while retaining knowledge of where that value was in some original list or array.

Since:
1.0
Author:
Jacob M. Litman
  • Constructor Details

    • DoubleIndexPair

      public DoubleIndexPair(int index, double doubleValue)
      Creates an instance of a DoubleIndexPair record class.
      Parameters:
      index - the value for the index record component
      doubleValue - the value for the doubleValue record component
  • Method Details

    • compareTo

      public int compareTo(DoubleIndexPair o)
      Specified by:
      compareTo in interface Comparable<DoubleIndexPair>
    • toString

      public String toString()
      Returns a string containing the index and double value.
      Specified by:
      toString in class Record
      Returns:
      a String object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • doubleValue

      public double doubleValue()
      Returns the value of the doubleValue record component.
      Returns:
      the value of the doubleValue record component