Package com.graphbuilder.math
Class VarMap
java.lang.Object
com.graphbuilder.math.VarMap
VarMap maps a name to a value. A VarMap is used in the eval method of an Expression object. This class can be used as the default variable-map.
During the evaluation of an expression, if a variable is not supported then a RuntimeException is thrown. Case sensitivity can only be specified in the constructor (for consistency). When case sensitivity is false, the String.equalsIgnoreCase method is used. When case sensitivity is true, the String.equals method is used. By default, case sensitivity is true.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value associated with the specified variable name.double[]Returns an array of exact length of the values stored in this map.String[]Returns an array of exact length of the variable names stored in this map.booleanReturns true if the case of the variable names is considered.voidRemoves the variable-name from the map.voidAssigns the value to the specified variable name.
-
Constructor Details
-
VarMap
public VarMap() -
VarMap
public VarMap(boolean caseSensitive)
-
-
Method Details
-
getValue
Returns the value associated with the specified variable name.- Throws:
RuntimeException- If a matching variable name cannot be found.
-
setValue
Assigns the value to the specified variable name.- Throws:
IllegalArgumentException- If the variable name is null.
-
isCaseSensitive
public boolean isCaseSensitive()Returns true if the case of the variable names is considered. -
getVariableNames
Returns an array of exact length of the variable names stored in this map. -
getValues
public double[] getValues()Returns an array of exact length of the values stored in this map. The returned array corresponds to the order of the names returned by getVariableNames. -
remove
Removes the variable-name from the map. Does nothing if the variable-name is not found.
-