Package com.singularsys.jep.functions
Class MinMax
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.ArrayFunctionBase
-
- 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 somin([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
Fields Modifier and Type Field Description 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
Constructors Constructor Description MinMax(boolean isMin)
Constructor.MinMax(Comparative comp)
Constructor allowing for a different Comparative object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, run, setZeroLengthErrorBehaviour, throwAtLeastOneExcep
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
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. TheComparative.compare(Object, Object)
method will be used to compare elements.- Parameters:
comp
- a Comparative object or subclass implemented less than or greater than.- 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 classArrayFunctionBase
- Parameters:
v
- The list to operate on. Note this is in reverse order of the arguments of the function.- Returns:
- The result of the calculation.
- Throws:
EvaluationException
- if the calculation cannot be performed
-
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
-
-