public class ReverseComparator
extends java.lang.Object
implements java.util.Comparator, java.io.Serializable
compare method.Collections.reverseOrder(),
Serialized Form| Constructor and Description |
|---|
ReverseComparator()
Creates a comparator that compares objects based on the inverse of their
natural ordering.
|
ReverseComparator(java.util.Comparator comparator)
Creates a comparator that inverts the comparison
of the given comparator.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compares two objects in reverse order.
|
boolean |
equals(java.lang.Object object)
Returns
true iff that Object is
is a Comparator whose ordering is known to be
equivalent to mine. |
int |
hashCode()
Implement a hash code for this comparator that is consistent with
equals. |
public ReverseComparator()
Collections.reverseOrder()public ReverseComparator(java.util.Comparator comparator)
null,
the ReverseComparator defaults to reversing the
natural order, as per
Collections.reverseOrder().comparator - Comparator to reversepublic int compare(java.lang.Object obj1,
java.lang.Object obj2)
compare in interface java.util.Comparatorobj1 - the first object to compareobj2 - the second object to comparepublic int hashCode()
equals.hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
true iff that Object is
is a Comparator whose ordering is known to be
equivalent to mine.
This implementation returns true
iff object.
equals getClass()this.getClass(), and the underlying
comparators are equal.
Subclasses may want to override this behavior to remain consistent
with the equals contract.
equals in interface java.util.Comparatorequals in class java.lang.Objectobject - the object to compare toCopyright © 2010 - 2023 Adobe. All Rights Reserved