java.lang.Object
net.automatalib.common.util.comparison.CmpUtil

public final class CmpUtil extends Object
Various methods for dealing with the comparison of objects.
  • Method Details

    • canonicalCompare

      public static <U> int canonicalCompare(List<? extends U> o1, List<? extends U> o2, Comparator<? super U> elemComparator)
      Compares two Lists with respect to canonical ordering.

      In canonical ordering, a sequence o1 is less than a sequence o2 if o1 is shorter than o2, or if they have the same length and o1 is lexicographically smaller than o2.

      Type Parameters:
      U - element type
      Parameters:
      o1 - the first list
      o2 - the second list
      elemComparator - the comparator for comparing the single elements
      Returns:
      the result of the comparison
    • canonicalCompare

      public static int canonicalCompare(int[] a1, int[] a2)
    • canonicalCompare

      public static <U extends Comparable<? super U>> int canonicalCompare(List<? extends U> o1, List<? extends U> o2)
      Compares two Lists of Comparable elements with respect to canonical ordering.

      In canonical ordering, a sequence o1 is less than a sequence o2 if o1 is shorter than o2, or if they have the same length and o1 is lexicographically smaller than o2.

      Type Parameters:
      U - element type
      Parameters:
      o1 - the first list
      o2 - the second list
      Returns:
      the result of the comparison
    • lexCompare

      public static <U> int lexCompare(Iterable<? extends U> o1, Iterable<? extends U> o2, Comparator<? super U> elemComparator)
      Lexicographically compares two Iterables. Comparison of the elements is done using the specified comparator.
      Type Parameters:
      U - element type
      Parameters:
      o1 - the first iterable.
      o2 - the second iterable.
      elemComparator - the comparator.
      Returns:
      < 0 iff o1 is lexicographically smaller, 0 if o1 equals o2 and > 0 otherwise.
    • lexCompare

      public static int lexCompare(int[] a1, int[] a2)
    • lexCompare

      public static <U extends Comparable<? super U>> int lexCompare(Iterable<? extends U> o1, Iterable<? extends U> o2)
      Lexicographically compares two Iterables using the inert comparability of their elements.
      Type Parameters:
      U - element type
      Parameters:
      o1 - the first iterable.
      o2 - the second iterable.
      Returns:
      < 0 iff o1 is lexicographically smaller, 0 if o1 equals o2 and > 0 otherwise.
    • lexComparator

      public static <T extends Iterable<U>, U> Comparator<T> lexComparator(Comparator<? super U> elemComp)
      Retrieves a lexicographical comparator for the given type.
      Type Parameters:
      U - element type
      T - iterable type
      Parameters:
      elemComp - the comparator to use for comparing the elements.
      Returns:
      a comparator for comparing iterables of type U based on lexicographical ordering.
    • lexComparator

      public static <U extends Comparable<U>, T extends Iterable<U>> Comparator<T> lexComparator()
      Retrieves a lexicographical comparator for the given type, which has to be an Iterable of Comparable types.
      Type Parameters:
      U - element type
      T - iterable type
      Returns:
      the lexicographical comparator.
    • canonicalComparator

      public static <T extends List<? extends U>, U> Comparator<T> canonicalComparator(Comparator<? super U> elemComp)
      Retrieves a canonical comparator for the given list type.
      Type Parameters:
      U - element type
      T - list type
      Parameters:
      elemComp - the comparator to use for comparing the elements.
      Returns:
      a comparator for comparing iterables of type U based on canonical ordering.
    • canonicalComparator

      public static <T extends List<U>, U extends Comparable<U>> Comparator<T> canonicalComparator()
      Retrieves a canonical comparator for the given type, which has to be a List of Comparable types.
      Type Parameters:
      U - element type
      T - list type
      Returns:
      the canonical comparator
      See Also: