|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.stanford.nlp.util.EntryValueComparator
Comparator for values of Map entries. Allows sorting in normal or reversed order. Values must implement Comparable to be used.
Example use (sorts map of counts with highest first):
Map counts = ... // Object key -> Integer/Double count List entries=new ArrayList(counts.entrySet()); Collections.sort(entries,new EntryValueComparator(false));
Constructor Summary | |
EntryValueComparator()
Constructs a new EntryValueComparator using ascending (normal) order that works on Map.Entry objects. |
|
EntryValueComparator(boolean ascending)
Constructs a new EntryValueComparator that will sort in the given order and works on Map.Entry objects. |
|
EntryValueComparator(Map m)
Constructs a new EntryValueComparator that will sort keys for the given Map in ascending (normal) order. |
|
EntryValueComparator(Map m,
boolean ascending)
Constructs a new EmptyValueComparator to sort keys or entries of the given map in the given order. |
Method Summary | |
int |
compare(Object o1,
Object o2)
Compares the values of the two given Map.Entry objects in the given order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
Constructor Detail |
public EntryValueComparator()
public EntryValueComparator(boolean ascending)
public EntryValueComparator(Map m)
public EntryValueComparator(Map m, boolean ascending)
m
- Map whose keys are to be sorted, or null if
Map.Entry objects will be sorted.ascending
- whether to sort in ascending (normal) order or
descending (reverse) order. Ascending order is alphabetical, descending
order puts higher numbers first.Method Detail |
public int compare(Object o1, Object o2)
compare
in interface Comparator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |