jdsl.core.ref
Class ComparatorReverser
java.lang.Object
jdsl.core.ref.AbstractComparator
jdsl.core.ref.ComparatorReverser
- All Implemented Interfaces:
- Comparator, EqualityComparator
- public class ComparatorReverser
- extends AbstractComparator
- implements Comparator
Takes a Comparator
and reverses the
ordering with respect to which the elements are compared.
- Version:
- JDSL 2.1.1
- Author:
- Don Blaheta (dpb), Luca Vismara (lv)
Method Summary |
int |
compare(Object a,
Object b)
A C-style comparison function that returns a negative value if the
first object is less than the second, a positive value if the second
object is less, and 0 if the two objects are equal. |
boolean |
isComparable(Object obj)
Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ComparatorReverser
public ComparatorReverser(Comparator cmp)
- Parameters:
cmp
- The comparator to be reversed.
compare
public int compare(Object a,
Object b)
- Description copied from interface:
Comparator
- A C-style comparison function that returns a negative value if the
first object is less than the second, a positive value if the second
object is less, and 0 if the two objects are equal.
- Specified by:
compare
in interface Comparator
- Specified by:
compare
in class AbstractComparator
- Returns:
- the negation of a
compare(Object,Object)
call to the slave comparator; so if the other comparator
guarantees some number with an absolute value greater than one,
that value will be preserved
isComparable
public boolean isComparable(Object obj)
- Description copied from interface:
EqualityComparator
- Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined.
- Specified by:
isComparable
in interface EqualityComparator
- Parameters:
obj
- Any java.lang.Object
- Returns:
- True if and only if this comparator may compare this object.