|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.molae.pipe.binop.AbstractBinaryFunction<S,S,T> net.sf.molae.pipe.binop.SymmetricBinaryFunction<T,T> net.sf.molae.pipe.sorted.Max<T>
public final class Max<T>
The binary function returning the maximum of two objects.
Min
Constructor Summary | |
---|---|
Max(Comparator<? super T> comparator)
Creates a new maximum function based on the specified comparator. |
|
Max(Comparator<? super T> comparator,
T negativeInfinity,
T positiveInfinity)
Creates a new maximum function with the specified properties. |
Method Summary | ||
---|---|---|
T |
compute(T arg1,
T arg2)
Compares the two specified objects and returns the greater one. |
|
static
|
getInstance()
Returns the default instance of this class. |
|
static
|
max(Collection<T> c)
Returns the greatest element from the specified collection. |
|
static
|
max(Collection<T> c,
Comparator<T> comparator)
Returns the greatest element from the specified collection using the specified comparator. |
Methods inherited from class net.sf.molae.pipe.binop.SymmetricBinaryFunction |
---|
getIdentityElement, getSink, isAnIdentityElement, isASink |
Methods inherited from class net.sf.molae.pipe.binop.AbstractBinaryFunction |
---|
getFirstInverse, getPermuted, isAssociative, isLeftSink, isRightIdentityElement, setFirstInverse, setPermuted, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Max(Comparator<? super T> comparator, T negativeInfinity, T positiveInfinity)
comparator
- comparator to use for comparison
or null
if natural ordering is usednegativeInfinity
- the negative infinity of the comparator
or null
if such an element does not exist.positiveInfinity
- the positive infinity of the comparator
or null
if such an element does not exist.public Max(Comparator<? super T> comparator)
comparator
- comparator to use for comparison
or null
if natural ordering is usedMethod Detail |
---|
public static <T extends Comparable<T>> Max<T> getInstance()
public T compute(T arg1, T arg2)
compute
in interface BinaryFunction<T,T,T>
compute
in class AbstractBinaryFunction<T,T,T>
arg1
- first object to comparearg2
- second object to compare
arg1
and arg2
.
If both are equal, arg1
is returned.
ClassCastException
- if arg1
and arg2
cannot be compared to one another using
the underlying comparator (or, if it is null
,
using natural ordering).
NullPointerException
- if o1
or o2
is null and natural order is used,
or if the comparator does not tolerate null elements.public static <T> T max(Collection<T> c, Comparator<T> comparator)
null
is returned.
c
- collection to searchcomparator
- comparator to use for comparison
or null
if natural ordering is used
public static <T extends Comparable<T>> T max(Collection<T> c)
null
is returned.
c
- collection to search
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |