net.sf.jga.util
Class GenericComparator<T,R extends java.lang.Comparable<? super R>>

java.lang.Object
  extended by net.sf.jga.util.GenericComparator<T,R>
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator<T>

public class GenericComparator<T,R extends java.lang.Comparable<? super R>>
extends java.lang.Object
implements java.util.Comparator<T>, java.io.Serializable

Comparator that applies a functor to each argument, then compares the results. The functor must return Comparable values.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Constructor Summary
GenericComparator(UnaryFunctor<T,R> fn)
          Builds a comparator that uses the given functor to derive the values that are to be compared.
 
Method Summary
 int compare(T x, T y)
          Applies the functor to each of the two arguments, and compares the results.
 
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

GenericComparator

public GenericComparator(UnaryFunctor<T,R> fn)
Builds a comparator that uses the given functor to derive the values that are to be compared.

Method Detail

compare

public int compare(T x,
                   T y)
Applies the functor to each of the two arguments, and compares the results.

Specified by:
compare in interface java.util.Comparator<T>


Copyright © 2002-2006 David A. Hall. All Rights Reserved.