unikl.disco.misc
Class MapValueComparator

java.lang.Object
  extended by unikl.disco.misc.MapValueComparator
All Implemented Interfaces:
java.util.Comparator

public class MapValueComparator
extends java.lang.Object
implements java.util.Comparator

A comparator that does not compare two objects directly but uses them as keys into a given map and comparing the resulting pair of values.

Author:
Frank A. Zdarsky

Constructor Summary
MapValueComparator(java.util.Map map)
          Creates an instance of MapValueComparator.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two objects indirectly by using them as keys into a map and comparing the resulting pair of values.
 
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

MapValueComparator

public MapValueComparator(java.util.Map map)
Creates an instance of MapValueComparator. The values in the provided map map must implement the interface Comparable.

Parameters:
map -
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two objects indirectly by using them as keys into a map and comparing the resulting pair of values.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 -
o2 -
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second