Map
Edit on GitHubA Map holds key-value pairs. Any value may be used as a key or value. Operations on a Map
mutate the internal state, so it never needs to be re-assigned.
Values
Map.make
Creates a new, empty map.
Map.makeSized
Creates a new, empty map with an initial storage size for the given number of elements.
Map.get
Retrieves the value associated with the given key from the map. Returns an optional result, with Some(value)
if it exists and None
if not.
Map.set
Adds a new key-value pair to the map. If the key already exists, replaces the value.
Map.update
Calls the updater function with the optional value at the key, with Some(value)
if it exists or None
if not. The updater function must return Some(newValue)
if a new value should be set or None
if the value should be removed from the map.
Map.contains
Returns true
if the map contains the given key.
Map.remove
Removes the key-value pair associated with the given key from the map.
Map.size
Returns the number of keys bound to a value within the map.
Map.isEmpty
Returns true
if the map contains no key-value pairs.
Map.clear
Removes all key-value pairs from the map.
Map.forEach
Iterates the given function over each key-value pair in the map.
Map.reduce
Reduces all key-value pairs within a map to a single value. The reducer function is called with the accumulator, the current key, and the current value.
Map.keys
Returns a list of all keys bound to a value in the map.
Map.values
Returns a list of all values bound to a key in the map.
Map.toList
Returns a list of all key-value pairs in the map.
Map.fromList
Creates a map from a list of key-value pairs.
Map.toArray
Returns a array of all key-value pairs in the map.
Map.fromArray
Creates a map from an array of key-value pairs.
Map.filter
Keeps all key-value pairs that the predicate returned true
for from the map.
Map.reject
Removes all key-value pairs that the predicate returned true
for from the map.