map
Functions
new
map.new() → const map<K, V>This function creates a new empty map of the specified key and value types.
Returns: const map<K, V>
Methods
clear
map.clear(map<K, V> m)This function clears all entries from the given map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to clear. |
contains
map.contains(map<K, V> m, K key) → boolThis function checks if the specified key exists in the given map.
It returns true if the key is found, otherwise false.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to search in. | |
key | K | The key to check for existence. |
Returns: bool
copy
map.copy(map<K, V> map) → map<K, V>This function creates a copy of the given map and returns the new map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
map | map<K, V> | The map to copy. |
Returns: map<K, V>
get
map.get(map<K, V> m, K key) → VThis function retrieves the value associated with the specified key in the given map, or returns na if the key does not exist.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to retrieve the value from. | |
key | K | The key to look up in the map. |
Returns: V — The value associated with key, or na if the key does not exist.
keys
map.keys(map<K, V> m) → array<K>This function returns an array containing all the keys present in the given map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to get the keys from. |
Returns: array<K>
put
map.put(map<K, V> m, K key, V value) → VThis function inserts or updates the value associated with the specified key in the given map.
It returns the previous value if the key existed, or na if it is a new entry.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to insert or update a value in. | |
key | K | The key to associate with the value. | |
value | V | The value to insert or update. |
Returns: V — The previous value associated with key, or na if the key was not previously present.
put_all
map.put_all(map<K, V> dest, map<K, V> src)This function copies all key-value pairs from the source map to the destination map.
Existing keys in the destination map will be updated with values from the source map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dest | map<K, V> | The destination map to copy values into. | |
src | map<K, V> | The source map to copy values from. |
remove
map.remove(map<K, V> m, K key) → VThis function removes the entry associated with the specified key from the given map.
It returns the removed value if the key existed, or na if the key was not found.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to remove a value from. | |
key | K | The key of the entry to remove. |
Returns: V — The removed value, or na if the key was not found.
size
map.size(map<K, V> m) → intThis function returns the number of key-value pairs currently stored in the given map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to get the size of. |
Returns: int
values
map.values(map<K, V> m) → array<V>This function returns an array containing all the values present in the given map.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
m | map<K, V> | The map to get the values from. |
Returns: array<V>