structure
Class ReverseComparator

java.lang.Object
  extended by structure.ReverseComparator
All Implemented Interfaces:
Comparator

public class ReverseComparator
extends Object
implements Comparator


Constructor Summary
ReverseComparator()
          Construct a comparator that generates reverse natural comparison
ReverseComparator(Comparator base)
          Construct a comparator that generates reverse of another comparator
 
Method Summary
 int compare(Object a, Object b)
          Compare two values, a and b.
 boolean equals(Object b)
          Returns true if the other object is a NaturalComparator.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReverseComparator

public ReverseComparator()
Construct a comparator that generates reverse natural comparison


ReverseComparator

public ReverseComparator(Comparator base)
Construct a comparator that generates reverse of another comparator

Parameters:
base - the ordering to be reversed
Method Detail

compare

public int compare(Object a,
                   Object b)
Compare two values, a and b. Simply calls the default compareTo method for a on b.

Specified by:
compare in interface Comparator
Parameters:
a - object performing the compare
b - the object being compared
Returns:
value <, ==, > 0 if a <, ==, > b using a.compareTo

equals

public boolean equals(Object b)
Returns true if the other object is a NaturalComparator.

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
b - a possible NaturalComparator
Returns:
true if b is a NaturalComparator