edu.stanford.nlp.util
Class Comparators
java.lang.Object
edu.stanford.nlp.util.Comparators
public class Comparators
- extends java.lang.Object
Method Summary |
static
<T> java.util.Comparator<T> |
|
chain(java.util.Comparator<T>... c)
|
static
<T> java.util.Comparator<T> |
|
chain(java.util.Comparator<T> c1,
java.util.Comparator<T> c2)
Returns a new Comparator which is the result of chaining the
given Comparator s. |
static
<T> java.util.Comparator<T> |
|
chain(java.util.List<java.util.Comparator<T>> c)
Returns a new Comparator which is the result of chaining the
given Comparator s. |
static
<T extends java.lang.Comparable<? super T>>
int |
|
nullSafeComparator(T one,
T two)
Returns a consistent ordering over two elements even if one of them is null
(as long as compareTo() is stable, of course). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Comparators
public Comparators()
chain
public static <T> java.util.Comparator<T> chain(java.util.Comparator<T> c1,
java.util.Comparator<T> c2)
- Returns a new
Comparator
which is the result of chaining the
given Comparator
s. If the first Comparator
considers two objects unequal, its result is returned; otherwise, the
result of the second Comparator
is returned. Facilitates
sorting on primary and secondary keys.
chain
public static <T> java.util.Comparator<T> chain(java.util.List<java.util.Comparator<T>> c)
- Returns a new
Comparator
which is the result of chaining the
given Comparator
s. Facilitates sorting on multiple keys.
chain
public static <T> java.util.Comparator<T> chain(java.util.Comparator<T>... c)
nullSafeComparator
public static <T extends java.lang.Comparable<? super T>> int nullSafeComparator(T one,
T two)
- Returns a consistent ordering over two elements even if one of them is null
(as long as compareTo() is stable, of course).
Adapted from http://stackoverflow.com/a/481836
Stanford NLP Group