Class IntDoublePair

  • All Implemented Interfaces:
    java.lang.Comparable<IntDoublePair>

    public class IntDoublePair
    extends java.lang.Object
    implements java.lang.Comparable<IntDoublePair>
    Pair storing an integer and a double.
    Since:
    0.2
    Author:
    Erich Schubert
    • Constructor Summary

      Constructors 
      Constructor Description
      IntDoublePair​(int first, double second)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareSwappedTo​(IntDoublePair other)
      Implementation of comparableSwapped interface, sorting by second then first.
      int compareTo​(IntDoublePair other)
      Implementation of comparable interface, sorting by first then second.
      boolean equals​(java.lang.Object obj)
      Trivial equals implementation
      int hashCode()
      Trivial hashCode implementation mixing the two integers.
      void setFirst​(int first)
      Set first value
      void setSecond​(double second)
      Set second value
      java.lang.String toString()
      Returns first and second value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • first

        public int first
        first value
      • second

        public double second
        second value
      • BYFIRST_COMPARATOR

        public static final java.util.Comparator<IntDoublePair> BYFIRST_COMPARATOR
        Comparator to compare by second component only
      • BYSECOND_COMPARATOR

        public static final java.util.Comparator<IntDoublePair> BYSECOND_COMPARATOR
        Comparator to compare by second component only
      • SWAPPED_COMPARATOR

        public static final java.util.Comparator<IntDoublePair> SWAPPED_COMPARATOR
        Comparator to compare by swapped components
    • Constructor Detail

      • IntDoublePair

        public IntDoublePair​(int first,
                             double second)
        Constructor
        Parameters:
        first - First value
        second - Second value
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Trivial equals implementation
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Object to compare to
      • hashCode

        public final int hashCode()
        Trivial hashCode implementation mixing the two integers.
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(IntDoublePair other)
        Implementation of comparable interface, sorting by first then second.
        Specified by:
        compareTo in interface java.lang.Comparable<IntDoublePair>
        Parameters:
        other - Object to compare to
        Returns:
        comparison result
      • compareSwappedTo

        public int compareSwappedTo​(IntDoublePair other)
        Implementation of comparableSwapped interface, sorting by second then first.
        Parameters:
        other - Object to compare to
        Returns:
        comparison result
      • setFirst

        public final void setFirst​(int 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()
        Returns first and second value.
        Overrides:
        toString in class java.lang.Object