ck/map▲toc

Map

.

type mapck/map/map: (V, V) -> V<a,b>
fun add( m : mapck/map/map: (V, V) -> V<a,b>, key : a, value : b, ?cmp : (a, a) -> orderstd/core/types/order: V ) : mapck/map/map: (V, V) -> V<a,b>

Add a key-value pair to a map. If the given key already exists, update the corresponding value. The time complexity is O(log size).

Check whether a map contains a key. The time complexity is O(log size).

Create an empty map.

fun foreach( m : mapck/map/map: (V, V) -> V<a,b>, action : (a, b) -> e () ) : e ()

Iterate over key-value pairs in ascending order of their keys.

fun foreach-key( m : mapck/map/map: (V, V) -> V<a,b>, action : (a) -> e () ) : e ()

Iterate over keys in ascending order.

Get the value of a specified key. The time complexity is O(log size).

Check whether a map is empty.

Return the key-value pair of the largest key in a map. The time complexity is O(log size).

Return the key-value pair of the smallest key in a map. The time complexity is O(log size).

fun remove( m : mapck/map/map: (V, V) -> V<a,b>, key : a, ?cmp : (a, a) -> orderstd/core/types/order: V ) : mapck/map/map: (V, V) -> V<a,b>

Remove a key and the corresponding value from a map. Do nothing if the given key does not exist. The time complexity is O(log size).

Return the number of key-value pairs. The time complexity is O(1).

Update the key-value pair of a specified key. If key already exists, replace the corresponding value v with f(Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(v)). Otherwise, add the pair of key and f(Nothingstd/core/types/Nothing: forall<a> maybe<a>). The time complexity is O(log size).

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/maybe2std/core/maybe2, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/lazystd/core/lazy, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core