Class IterableComparator<T>

  • All Implemented Interfaces:
    Comparator<Iterable<T>>

    public class IterableComparator<T>
    extends Object
    implements Comparator<Iterable<T>>
    TODO: Move to com.ibm.icu.dev.somewhere. 2015-sep-03: Not used in ICU but used in CLDR and in UnicodeTools.
    • Constructor Detail

      • IterableComparator

        public IterableComparator()
      • IterableComparator

        public IterableComparator​(Comparator<T> comparator)
      • IterableComparator

        public IterableComparator​(Comparator<T> comparator,
                                  boolean shorterFirst)
    • Method Detail

      • compare

        public int compare​(Iterable<T> a,
                           Iterable<T> b)
        Description copied from interface: Comparator
        Compares the two specified objects to determine their relative ordering. The ordering implied by the return value of this method for all possible pairs of (lhs, rhs) should form an equivalence relation. This means that
        • compare(a,a) returns zero for all a
        • the sign of compare(a,b) must be the opposite of the sign of compare(b,a) for all pairs of (a,b)
        • From compare(a,b) > 0 and compare(b,c) > 0 it must follow compare(a,c) > 0 for all possible combinations of (a,b,c)
        Specified by:
        compare in interface Comparator<T>
        Parameters:
        a - an Object.
        b - a second Object to compare with lhs.
        Returns:
        an integer < 0 if lhs is less than rhs, 0 if they are equal, and > 0 if lhs is greater than rhs.
      • compareIterables

        public static <T> int compareIterables​(Iterable<T> a,
                                               Iterable<T> b)