Class Comparer


  • public class Comparer
    extends java.lang.Object
    Compares two different strings. Used in the various sorting algorithms.
    • Constructor Summary

      Constructors 
      Constructor Description
      Comparer​(Comparison comparison)
      Creates the comparer, and sets a comparison mode
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.String a, java.lang.String b)
      Compares the two strings using the set comparison mode.
      void setComparisonMode​(Comparison comparison)
      Sets the comparison mode
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Comparer

        public Comparer​(Comparison comparison)
        Creates the comparer, and sets a comparison mode
        Parameters:
        comparison - The mode of comparison the comparer should use
    • Method Detail

      • setComparisonMode

        public void setComparisonMode​(Comparison comparison)
        Sets the comparison mode
        Parameters:
        comparison - The mode of comparison the comparer should use
      • compare

        public int compare​(java.lang.String a,
                           java.lang.String b)
        Compares the two strings using the set comparison mode.
        Parameters:
        a - The first string to compare
        b - The second string to compare
        Returns:
        0 if a == b; 1 if a > b, -1 if a < b