3.31. kink/container/MAP

Operations for maps.

3.31.1. type map

A container mapping from keys to vals.

Equivalence of keys is defined by each map implementation.

Map.set(Key Val)

Associates the Key to the Val.

If the Map contains a key equivalent to the Key, it depends on implementation whether the key is replaced by the new Key or not.

Map.get(Key)

Returns the val associated to the Key.

Precondition: the Map must contains a key equivalent to the Key.

Map.get_or(Key $supply_default)

Returns the val associated to the Key, or tail-calls the thunk $supply_default if such a key does not exist.

Map.get_maybe(Key)

get_maybe returns [Val] if Val is associated with Key in the map, or [] if the Key does not exist.

Map.have_key?(Key)

Returns true if the Map contains a key equivalent to the Key, otherwise returns false.

Map.size

Returns the size of the Map, that is, the number of the key-val entries.

Map.empty?

Returns true the Map contains no entry, otherwise returns false.

Map.op_eq(Another_map)

Returns true if Map and Another_map have the equivalent set of keys, and equal vals corresponding to the keys.

Equivalence of keys must be defined as the same between two maps.

Equality of vals are tested by Val == Another_val.

Map.pop_at(Key)

Pops the val associated to the Key.

Precondition: the Map must contains a key equivalent to the Key.

Map.clear

Removes all the entries.

Map.set_each_pair(Pair_eacher)

Sets each key-val entries in the Pair_eacher.

Pair_eacher is an eacher, which yields pair lists of [key val].

Map.key_iter

Iter of the keys.

Map.pair_iter

Iter of the pairs of [key val].

3.31.2. MAP.is?(Val)

`is?` returns whether `Val` is a map.