org.jutil.java.collections
Class InverseComparator

java.lang.Object
  |
  +--org.jutil.java.collections.ExtendedComparator
        |
        +--org.jutil.java.collections.InverseComparator
All Implemented Interfaces:
java.util.Comparator

public class InverseComparator
extends ExtendedComparator

An ExtendedComparator that inverts another Comparator.

Version:
$Revision: 1.2 $
Author:
Tom Schrijvers

Constructor Summary
InverseComparator(java.util.Comparator comparator)
          public behavior

pre comparator != null;

post getComparator() == comparator;
Initialize a new InverseComparator with the given comparator.
 
Method Summary
 int compare(java.lang.Object first, java.lang.Object second)
          public behavior

post \result == -getComparator().compare(first, second);
Return the inverse of the what the inverted comparator would return.
 java.util.Comparator getComparator()
          public behavior

post \result != null;
Return the comparator inverted by this.
 
Methods inherited from class org.jutil.java.collections.ExtendedComparator
ensureExtended, greater, max, min, notGreater, notSmaller, smaller
 
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
 

Constructor Detail

InverseComparator

public InverseComparator(java.util.Comparator comparator)
public behavior

pre comparator != null;

post getComparator() == comparator;
Initialize a new InverseComparator with the given comparator.
Parameters:
comparator - The comparator to invert.
Method Detail

getComparator

public java.util.Comparator getComparator()
public behavior

post \result != null;
Return the comparator inverted by this.

compare

public int compare(java.lang.Object first,
                   java.lang.Object second)
public behavior

post \result == -getComparator().compare(first, second);
Return the inverse of the what the inverted comparator would return.
Parameters:
first - The left-hand side object
second - The right-hand side object