|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.util.InvertedComparator
Compares objects, inverting either their natural order or the order of a wrapped comparator. This means that number objects will be sorted in decreasing order etc.
Constructor Summary | |
InvertedComparator()
Creates a new instance, inverting the natural order of objects. |
|
InvertedComparator(Comparator wrappedComp)
Creates a new instance, inverting the order returned by the provided comparator. |
Method Summary | |
int |
compare(Object o1,
Object o2)
Compares its two arguments for order. |
Comparator |
getWrappedComparator()
Returns the comparator wrapped and inverted by this instance; or null if the natural order of objects is inverted. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
Constructor Detail |
public InvertedComparator()
public InvertedComparator(Comparator wrappedComp)
wrappedComp
- the comparator to wrap and invert;
or null
if the natural order of objects should be invertedMethod Detail |
public int compare(Object o1, Object o2) throws ClassCastException
wrapped comparator
, if any. So this method returns a negative integer,
zero, or a positive integer as the first argument is greater than,
equal to, or less than the second.
compare
in interface Comparator
o1
- the first object to be comparedo2
- the second object to be compared
ClassCastException
- if the arguments' types prevent them from
being comparedpublic Comparator getWrappedComparator()
null
if the natural order of objects is inverted.
public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |