Class MakeMap
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NaryFunction
com.singularsys.jep.misc.dictionary.MakeMap
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
Create a map of a given type, either
creates an empty map or uses a list or map of data.
* jep.addFunction("hashMap", new MakeMap(MakeMap.Type.HashMap));
jep.addFunction("linkedMap", new MakeMap(MakeMap.Type.LinkedMap));
jep.addFunction("treeMap", new MatrixDictMakeMap(MakeMap.Type.TreeMap));
jep.addFunction("mymap",
new MakeMap(() ->
new TreeMap<Object,Object>( (x,y) ->
Double.compare(
((Number) x).doubleValue(),
((Number) y).doubleValue() ) ) );
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckNumberOfParameters(int n) Checks the number of parameters of the function.Evaluate the functionReturn a description of the function from the properties file.Methods inherited from class com.singularsys.jep.functions.NaryFunction
runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Field Details
-
nullValue
-
sup
-
type
-
-
Constructor Details
-
MakeMap
Create maps of a given type.- Parameters:
type- configurations type- Throws:
IllegalArgumentException- if type isMakeMap.Type.Supplier.
-
MakeMap
Create a map with a given supplier. For examplejep.addFunction("mymap", new MakeMap(() -> new TreeMap<Object,Object>( (x,y) -> Double.compare( ((Number) x).doubleValue(), ((Number) y).doubleValue() ) ) );- Parameters:
sup- a supplied that created maps.
-
-
Method Details
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n) Description copied from class:PostfixMathCommandChecks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method- Specified by:
checkNumberOfParametersin interfacePostfixMathCommandI- Overrides:
checkNumberOfParametersin classPostfixMathCommand- Parameters:
n- number of parameters function will be called with.- Returns:
- false if an illegal number of parameters is supplied, true otherwise.
-
eval
Description copied from class:NaryFunctionEvaluate the function- Specified by:
evalin classNaryFunction- Parameters:
args- arguments to the function- Returns:
- value returned by the function
- Throws:
EvaluationException- if the calculation cannot be performed
-
getDescription
Description copied from class:PostfixMathCommandReturn a description of the function from the properties file. The property name is the class name followed by ".description". The property is found using theJepMessagesclass, which can be configured to add additional properties files. IfPostfixMathCommand.setDescription(String)has been called, return the description set by that method instead.- Specified by:
getDescriptionin interfacePostfixMathCommandI- Overrides:
getDescriptionin classPostfixMathCommand- Returns:
- the description of the function
-