docs / map

map

Types

Map

Functions

contains

fn(map: Map<'k, 'v>, key: 'k) -> Bool

Returns true if the map contains the given key.

each_key

fn(map: Map<'k, 'v>, f: fn ('k) -> () / 't2612) -> () / { 't2612 }

Calls f once for each key in the map.

from_entries

fn(entries: Array<('k, 'v)>) -> Map<'k, 'v>

Builds a map from an array of key-value pairs. If duplicate keys are present, the last entry wins.

get

fn(map: Map<'k, 'v>, key: 'k) -> Option<'v>

Looks up a key in the map, returning Some(value) if found or None if absent.

insert

fn(map: Map<'k, 'v>, key: 'k, value: 'v) -> Map<'k, 'v>

Returns a new map with the given key-value pair added. If the key already exists, its value is replaced.

is_empty

fn(map: Map<'k, 'v>) -> Bool

Returns true if the map contains no entries.

length

fn(map: Map<'k, 'v>) -> Int

Returns the number of entries in the map.

new

'k , 'v . fn () -> Map<'k, 'v>

Creates an empty map.

remove

fn(map: Map<'k, 'v>, key: 'k) -> Map<'k, 'v>

Returns a new map with the given key removed. If the key is not present, the map is returned unchanged.

union

fn(a: Map<'k, 'v>, b: Map<'k, 'v>) -> Map<'k, 'v>

Merges two maps. When both maps contain the same key, the value from b is kept.