Class SortedPair

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

    public class SortedPair
    extends java.lang.Object
    implements java.lang.Comparable<SortedPair>
    SortedPair class is used in the Separation table. It holds a pair of integers and ensures that they are sorted such that the first value is larger than the second. The Sorted pair is used to ensure that duplicate values are not stored in the separation table and that the Hashtable can be keyed on both atom indices.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int a  
      int b  
    • Constructor Summary

      Constructors 
      Constructor Description
      SortedPair​(int a, int b)
      Construct a new SortedPair.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(SortedPair that)
      Compares this object with another.
      boolean equals​(java.lang.Object obj)
      Returns true if this SortedPair is equal with another object.
      int hashCode()
      Returns the hash code of this sorted pair object.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • a

        public final int a
      • b

        public final int b
    • Constructor Detail

      • SortedPair

        public SortedPair​(int a,
                          int b)
        Construct a new SortedPair. Make sure that A > B.
    • Method Detail

      • hashCode

        public int hashCode()
        Returns the hash code of this sorted pair object. Defined as the XOR of the hashes of A and B.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code.
      • equals

        public boolean equals​(java.lang.Object obj)
        Returns true if this SortedPair is equal with another object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - The object to compare with.
        Returns:
        True if SortedPair and object are equal.
      • compareTo

        public int compareTo​(SortedPair that)
        Compares this object with another. This allows collections of SortedPairs to be sorted using the java standard library sorting algorithms.
        Specified by:
        compareTo in interface java.lang.Comparable<SortedPair>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object