Class IntPair

java.lang.Object
jme3utilities.math.IntPair
All Implemented Interfaces:
Comparable<IntPair>

public class IntPair extends Object implements Comparable<IntPair>
Represent a pair of distinct integers. Immutable.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Logger
    message logger for this class
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntPair(int a, int b)
    Instantiate a pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(IntPair otherPair)
    Compare to another IntPair, with the smaller elements having priority.
    boolean
    equals(Object otherObject)
    Test for exact equivalence with another Object.
    int
    Generate the hash code for this pair.
    int
    Read the larger element of the pair.
    int
    Read the smaller element of the pair.
    Represent this pair as a text string.

    Methods inherited from class java.lang.Object

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

    • logger

      public static final Logger logger
      message logger for this class
  • Constructor Details

    • IntPair

      public IntPair(int a, int b)
      Instantiate a pair.
      Parameters:
      a - the first element (≠ b)
      b - the 2nd element (≠ a)
  • Method Details

    • larger

      public int larger()
      Read the larger element of the pair.
      Returns:
      the element value
    • smaller

      public int smaller()
      Read the smaller element of the pair.
      Returns:
      the element value
    • compareTo

      public int compareTo(IntPair otherPair)
      Compare to another IntPair, with the smaller elements having priority.
      Specified by:
      compareTo in interface Comparable<IntPair>
      Parameters:
      otherPair - (not null)
      Returns:
      0 if this equals otherPair; negative if this comes before otherPair; positive if this comes after otherPair
    • equals

      public boolean equals(Object otherObject)
      Test for exact equivalence with another Object.
      Overrides:
      equals in class Object
      Parameters:
      otherObject - the object to compare (may be null, unaffected)
      Returns:
      true if this and otherObject have identical values, otherwise false
    • hashCode

      public int hashCode()
      Generate the hash code for this pair.
      Overrides:
      hashCode in class Object
      Returns:
      a 32-bit value for use in hashing
    • toString

      public String toString()
      Represent this pair as a text string. The format is: {smaller,larger}
      Overrides:
      toString in class Object
      Returns:
      a descriptive string of text (not null)