Package com.singularsys.jep.misc.dictionary

# Class Put

java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NaryFunction
com.singularsys.jep.misc.dictionary.Put

All Implemented Interfaces:
  `PostfixMathCommandI`, `Serializable`

public class Put extends NaryFunction
Puts a key-value pair into a map.

    map = {'x':2, 'y':3};
    put(map, 'x', 4);
    put(map, 'z', 5);

The function either returns the previous value associated with the key or the nullValue.

Since:
  Jep 4.1
See Also:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Put.Type`
  Configuration type

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Object`
  `nullValue`
  `final Put.Type`
  `type`

  ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Put(Put.Type type, Object nullValue)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `checkNumberOfParameters(int n)`
  Checks the number of parameters of the function.
  `protected boolean`
  `equals(Object key, Object k)`
  Test if key equals k.
  `Object`
  `eval(Object[] args)`
  Evaluate the function
  `protected Object`
  `eval(List<Object> list, Object key, Object val)`
  `protected Object`
  `eval(Map<Object,Object> map, Object key, Object val)`

  ### Methods inherited from class com.singularsys.jep.functions.NaryFunction

  `run`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### nullValue

    protected Object nullValue

  - ### type

    public final Put.Type type

- ## Constructor Details

  - ### Put

    public Put(Put.Type type, Object nullValue)

- ## Method Details

  - ### checkNumberOfParameters

    public boolean checkNumberOfParameters(int n)
    Description copied from class: `PostfixMathCommand`
    Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method
    Specified by:
      `checkNumberOfParameters` in interface `PostfixMathCommandI`
    Overrides:
      `checkNumberOfParameters` in class `PostfixMathCommand`
    Parameters:
      `n` - number of parameters function will be called with.
    Returns:
      false if an illegal number of parameters is supplied, true otherwise.

  - ### eval

    public Object eval(Object[] args) throws EvaluationException
    Description copied from class: `NaryFunction`
    Evaluate the function
    Specified by:
      `eval` in class `NaryFunction`
    Parameters:
      `args` - arguments to the function
    Returns:
      value returned by the function
    Throws:
      `EvaluationException` - if the calculation cannot be performed

  - ### eval

    protected Object eval(Map<Object,Object> map, Object key, Object val)

  - ### eval

    protected Object eval(List<Object> list, Object key, Object val) throws EvaluationException
    Throws:
      `EvaluationException`

  - ### equals

    protected boolean equals(Object key, Object k) throws EvaluationException
    Test if key equals k. Default implementation uses `key.equals(k)`
    Parameters:
      `key` - key to test
      `k` - key to test
    Returns:
      true if parameters are equal
    Throws:
      `EvaluationException`