@Beta @GwtCompatible public final class Comparators extends Object
Comparator instances. For many other helpful
 comparator utilities, see either Comparator itself (for Java 8 or later), or com.google.common.collect.Ordering (otherwise).
 OrderingIn light of the significant enhancements to Comparator in Java 8, the overwhelming
 majority of usages of Ordering can be written using only built-in JDK APIs. This class is
 intended to "fill the gap" and provide those features of Ordering not already provided by
 the JDK.
| Modifier and Type | Method and Description | 
|---|---|
static <T> boolean | 
isInOrder(Iterable<? extends T> iterable,
         Comparator<T> comparator)
Returns  
true if each element in iterable after the first is greater than or
 equal to the element that preceded it, according to the specified comparator. | 
static <T> boolean | 
isInStrictOrder(Iterable<? extends T> iterable,
               Comparator<T> comparator)
Returns  
true if each element in iterable after the first is strictly
 greater than the element that preceded it, according to the specified comparator. | 
static <T,S extends T> | 
lexicographical(Comparator<T> comparator)
Returns a new comparator which sorts iterables by comparing corresponding elements pairwise
 until a nonzero result is found; imposes "dictionary order." If the end of one iterable is
 reached, but not the other, the shorter iterable is considered to be less than the longer one. 
 | 
public static <T,S extends T> Comparator<Iterable<S>> lexicographical(Comparator<T> comparator)
[] < [1] < [1,
 1] < [1, 2] < [2].
 Note that Collections.reverseOrder(lexicographical(comparator)) is not equivalent to
 lexicographical(Collections.reverseOrder(comparator)) (consider how each would order
 [1] and [1, 1]).
public static <T> boolean isInOrder(Iterable<? extends T> iterable, Comparator<T> comparator)
true if each element in iterable after the first is greater than or
 equal to the element that preceded it, according to the specified comparator. Note that this is
 always true when the iterable has fewer than two elements.public static <T> boolean isInStrictOrder(Iterable<? extends T> iterable, Comparator<T> comparator)
true if each element in iterable after the first is strictly
 greater than the element that preceded it, according to the specified comparator. Note that
 this is always true when the iterable has fewer than two elements.Copyright © 2010–2018. All rights reserved.