net.sf.jga.fn.algorithm

Class MinValue<T>

public class MinValue<T> extends AbstractUnaryFunctor<Collection<? extends T>,T> implements Serializable

Identifies the smallest value in a collection.

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceMinValue.Visitor
Interface for classes that may interpret an MinValue functor.
Constructor Summary
MinValue(Comparator<T> comp)
Builds a MinValue functor that will use the given comparator to compare elements in the collection.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(MinValue) method, if it implements the nested Visitor interface.
Tfn(Collection<? extends T> collection)
Return the smallest value in the collection
Comparator<T>getComparator()
Returns the functor used to order values in the collection.
StringtoString()

Constructor Detail

MinValue

public MinValue(Comparator<T> comp)
Builds a MinValue functor that will use the given comparator to compare elements in the collection. Typically, the functor would compare its two arguments and return the lesser value.

Throws: IllegalArgumentException if the Comparator is null

Method Detail

accept

public void accept(Visitor v)
Calls the Visitor's visit(MinValue) method, if it implements the nested Visitor interface.

fn

public T fn(Collection<? extends T> collection)
Return the smallest value in the collection

Throws: NoSuchElementException if the collection is empty

getComparator

public Comparator<T> getComparator()
Returns the functor used to order values in the collection.

toString

public String toString()