4.31. kink/container/MAP

Operations for maps.

4.31.1. type map

A container mapping from keys to vals.

Equivalence of keys is defined by each map implementation.

4.31.1.1. 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.

4.31.1.2. Map.get(Key)

Returns the val associated to the Key.

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

4.31.1.3. 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.

4.31.1.4. Map.get_maybe(Key)

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

4.31.1.5. Map.have_key?(Key)

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

4.31.1.6. Map.size

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

4.31.1.7. Map.empty?

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

4.31.1.8. 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.

4.31.1.9. Map.pop_at(Key)

Pops the val associated to the Key.

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

4.31.1.10. Map.clear

Removes all the entries.

4.31.1.11. Map.set_pairs(Pair_eacher)

Sets each key-val entries in the Pair_eacher.

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

4.31.1.12. Map.key_iter

Iter of the keys.

4.31.1.13. Map.pair_iter

Iter of the pairs of [key val].

4.31.2. MAP.is?(Val)

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