com.singularsys.jep.functions
Class MinMax

java.lang.Object
  extended by com.singularsys.jep.functions.PostfixMathCommand
      extended by com.singularsys.jep.functions.ArrayFunctionBase
          extended by com.singularsys.jep.functions.MinMax
All Implemented Interfaces:
PostfixMathCommandI, java.io.Serializable

public class MinMax
extends ArrayFunctionBase

Minimum and Maximum functions. Initialize with true for minimum and false for maximum. Since Jep 3.4 this function will flatten its arguments so min([1,[2,3]]) will be 1.

Since:
3.1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.singularsys.jep.functions.ArrayFunctionBase
ArrayFunctionBase.ZeroLengthErrorBehaviour
 
Field Summary
protected  Comparative comp
          Used to compare greater than or less than between objects.
 
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
 
Constructor Summary
MinMax(boolean isMin)
          Constructor.
MinMax(Comparative comp)
          Constructor allowing for a different Comparative object.
 
Method Summary
protected  java.lang.Object calc(java.util.List<java.lang.Object> v)
          Abstract method for performing the array calculation.
 Comparative getComp()
          Return the Comparative objected used to order the objects.
 java.lang.Object minmax(java.util.List<java.lang.Object> vals)
           
 
Methods inherited from class com.singularsys.jep.functions.ArrayFunctionBase
checkNumberOfParameters, getZeroLengthErrorBehaviour, run, setZeroLengthErrorBehaviour, throwAtLeastOneExcep
 
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected Comparative comp
Used to compare greater than or less than between objects.

Constructor Detail

MinMax

public MinMax(boolean isMin)
Constructor.

Parameters:
isMin - set to true for Minimum, false for Maximum

MinMax

public MinMax(Comparative comp)
Constructor allowing for a different Comparative object. The Comparative.compare(Object, Object) method will be used to compare elements.

Parameters:
comp -
Since:
3.4.0
Method Detail

calc

protected java.lang.Object calc(java.util.List<java.lang.Object> v)
                         throws EvaluationException
Description copied from class: ArrayFunctionBase
Abstract method for performing the array calculation.

Specified by:
calc in class ArrayFunctionBase
Parameters:
v - The list to operate on.
Returns:
The result of the calculation.
Throws:
EvaluationException

minmax

public java.lang.Object minmax(java.util.List<java.lang.Object> vals)
                        throws EvaluationException
Throws:
EvaluationException

getComp

public Comparative getComp()
Return the Comparative objected used to order the objects.

Returns:
the Comparative object
Since:
3.4.0


Copyright © 2010 Singular Systems http://www.singularsys.com/jep