MutableMapOps
Mutable map operations.
Table of Contents
- getOrElseUpdate() : mixed
- Returns associated value if given key is already in this map. Otherwise, computes value from given expression op, stores with key in map and returns that value.
- offsetSet() : void
- PHP magic method: offsetSet.
- offsetUnset() : void
- PHP magic method: offsetUnset.
- remove() : Option
- Removes a key from this map, returning the value associated previously with that key as an Option.
- update() : void
- Adds a new key/value pair to this map.
Methods
getOrElseUpdate()
Returns associated value if given key is already in this map. Otherwise, computes value from given expression op, stores with key in map and returns that value.
public
getOrElseUpdate(int|string $key, Closure $op) : mixed
Parameters
- $key : int|string
-
the key to test.
- $op : Closure
-
a closure returns the value to associate with key, if key is previously unbound.
Return values
mixed —the value associated with key (either previously or as a result of executing the method).
offsetSet()
PHP magic method: offsetSet.
public
offsetSet( $offset, $value) : void
Parameters
Return values
void —offsetUnset()
PHP magic method: offsetUnset.
public
offsetUnset( $offset) : void
Parameters
Return values
void —remove()
Removes a key from this map, returning the value associated previously with that key as an Option.
public
remove(int|string $key) : Option
Parameters
- $key : int|string
-
the key to be removed.
Return values
Option —an Option value containing the value associated previously with key, or None if key was not defined in the map before.
update()
Adds a new key/value pair to this map.
public
update(int|string $key, mixed $value) : void
If the map already contains a mapping for the key, it will be overridden by the new value.
Parameters
- $key : int|string
-
the key to update.
- $value : mixed
-
the new value.