Skip to content

map

Functions

new

pine
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

pine
map.clear(map<K, V> m)

This function clears all entries from the given map.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to clear.

contains

pine
map.contains(map<K, V> m, K key) → bool

This function checks if the specified key exists in the given map.

It returns true if the key is found, otherwise false.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to search in.
keyKThe key to check for existence.

Returns: bool


copy

pine
map.copy(map<K, V> map) → map<K, V>

This function creates a copy of the given map and returns the new map.

Parameters

NameTypeDefaultDescription
mapmap<K, V>The map to copy.

Returns: map<K, V>


get

pine
map.get(map<K, V> m, K key) → V

This function retrieves the value associated with the specified key in the given map, or returns na if the key does not exist.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to retrieve the value from.
keyKThe key to look up in the map.

Returns: V — The value associated with key, or na if the key does not exist.


keys

pine
map.keys(map<K, V> m) → array<K>

This function returns an array containing all the keys present in the given map.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to get the keys from.

Returns: array<K>


put

pine
map.put(map<K, V> m, K key, V value) → V

This 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

NameTypeDefaultDescription
mmap<K, V>The map to insert or update a value in.
keyKThe key to associate with the value.
valueVThe value to insert or update.

Returns: V — The previous value associated with key, or na if the key was not previously present.


put_all

pine
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

NameTypeDefaultDescription
destmap<K, V>The destination map to copy values into.
srcmap<K, V>The source map to copy values from.

remove

pine
map.remove(map<K, V> m, K key) → V

This 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

NameTypeDefaultDescription
mmap<K, V>The map to remove a value from.
keyKThe key of the entry to remove.

Returns: V — The removed value, or na if the key was not found.


size

pine
map.size(map<K, V> m) → int

This function returns the number of key-value pairs currently stored in the given map.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to get the size of.

Returns: int


values

pine
map.values(map<K, V> m) → array<V>

This function returns an array containing all the values present in the given map.

Parameters

NameTypeDefaultDescription
mmap<K, V>The map to get the values from.

Returns: array<V>

Released under the MIT License.