Module math

Class IntIntPair

java.lang.Object
de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair
All Implemented Interfaces:
PairInterface<Integer,Integer>, Comparable<IntIntPair>

public class IntIntPair extends Object implements Comparable<IntIntPair>, PairInterface<Integer,Integer>
Pair storing two integers. Since int is a native type, this can't be done via the CPair generic.
Author:
Erich Schubert
  • Field Details

    • first

      public int first
      first value
    • second

      public int second
      second value
    • BYFIRST_COMPARATOR

      public static final Comparator<IntIntPair> BYFIRST_COMPARATOR
      Comparator to compare by second component only
    • BYSECOND_COMPARATOR

      public static final Comparator<IntIntPair> BYSECOND_COMPARATOR
      Comparator to compare by second component only
    • SWAPPED_COMPARATOR

      public static final Comparator<IntIntPair> SWAPPED_COMPARATOR
      Comparator to compare by swapped components
  • Constructor Details

    • IntIntPair

      public IntIntPair(int first, int second)
      Constructor
      Parameters:
      first - First value
      second - Second value
  • Method Details

    • equals

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

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

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

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

      @Deprecated public final Integer getFirst()
      Deprecated.
      use pair.first to avoid boxing!
      Description copied from interface: PairInterface
      Get the first object - note: this may cause autoboxing, use pair.first for native pairs!
      Specified by:
      getFirst in interface PairInterface<Integer,Integer>
      Returns:
      First object
    • setFirst

      public final void setFirst(int first)
      Set first value
      Parameters:
      first - new value
    • getSecond

      @Deprecated public final Integer getSecond()
      Deprecated.
      use pair.first to avoid boxing!
      Description copied from interface: PairInterface
      Get the second object - note: this may cause autoboxing, use pair.second for native pairs!
      Specified by:
      getSecond in interface PairInterface<Integer,Integer>
      Returns:
      Second object
    • setSecond

      public final void setSecond(int second)
      Set second value
      Parameters:
      second - new value
    • toString

      public String toString()
      Overrides:
      toString in class Object