|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jga.fn.Functor<R> net.sf.jga.fn.BinaryFunctor<T,T,java.lang.Integer> net.sf.jga.fn.comparison.ComparatorFn<T>
public class ComparatorFn<T>
Functor wrapper around Comparator object. Allows Comparators to be used anywhere a Functor returning an Integer could have been used. Also implements Comparator as well, so an instance of this class could be used anywhere that the constructor argument could be used.
To Serialize a ComparatorFn, the Comparator given at construction must be Serializable.
Copyright © 2002-2005 David A. Hall
Nested Class Summary | |
---|---|
static interface |
ComparatorFn.Visitor
Interface for classes that may interpret a ComparatorFn functor. |
Constructor Summary | |
---|---|
ComparatorFn(java.util.Comparator<T> comp)
Builds the ComparatorFn wrapped around the given Comparator. |
Method Summary | |
---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(ComperatorFn) method, if it
implements the nested Visitor interface. |
int |
compare(T x,
T y)
|
java.lang.Integer |
fn(T x,
T y)
Given arguments x and y, return the result of the Comparator's compare(x,y) method, wrapped in an Integer. |
java.util.Comparator<T> |
getComparator()
Returns the comparator in use by this functor |
java.lang.String |
toString()
|
Methods inherited from class net.sf.jga.fn.BinaryFunctor |
---|
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth |
Methods inherited from class net.sf.jga.fn.Functor |
---|
composeNth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Constructor Detail |
---|
public ComparatorFn(java.util.Comparator<T> comp)
java.lang.NullPointerException
- if no Comparator is passed.Method Detail |
---|
public java.util.Comparator<T> getComparator()
public java.lang.Integer fn(T x, T y)
compare(x,y)
method, wrapped in an Integer.
Whether or not a NullPointerException is thrown if either x or y are
null is up to the Comparator
fn
in class BinaryFunctor<T,T,java.lang.Integer>
compare(x,y)
methodpublic void accept(Visitor v)
visit(ComperatorFn)
method, if it
implements the nested Visitor interface.
accept
in interface Visitable
accept
in class Functor<java.lang.Integer>
public int compare(T x, T y)
compare
in interface java.util.Comparator<T>
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |