org.jutil.java.comparator
Class InverseComparator
java.lang.Object
|
+--org.jutil.java.comparator.ExtendedComparator
|
+--org.jutil.java.comparator.InverseComparator
- All Implemented Interfaces:
- java.util.Comparator
- public class InverseComparator
- extends ExtendedComparator
An ExtendedComparator that inverts another Comparator.
|
Constructor Summary |
InverseComparator(java.util.Comparator comparator)
Initialize a new InverseComparator with the given comparator. |
|
Method Summary |
int |
compare(java.lang.Object first,
java.lang.Object second)
Return the inverse of the what the
inverted comparator would return. |
java.util.Comparator |
getComparator()
Return the comparator inverted by this. |
| 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 |
CVS_REVISION
public static final java.lang.String CVS_REVISION
InverseComparator
public InverseComparator(java.util.Comparator comparator)
- Initialize a new InverseComparator with the given comparator.
- Parameters:
comparator - The comparator to invert.
- Specifications:
-
public behavior
requires comparator != null;
ensures getComparator() == comparator;
getComparator
public java.util.Comparator getComparator()
- Return the comparator inverted by this.
- Specifications:
-
public behavior
ensures \result != null;
compare
public int compare(java.lang.Object first,
java.lang.Object second)
- Return the inverse of the what the
inverted comparator would return.
- Parameters:
first - The left-hand side objectsecond - The right-hand side object
- Specifications:
- also
-
public behavior
ensures \result == -getComparator().compare(first,second);