ATSLIB/libats/funmap_list
This package implements functional maps based on lists.
Note that this is only practical for maps of short size (e.g.,
containing only a few dozens keys).
Synopsis
typedef map(key:t0p, itm:t0p) = map_type(key, itm)
Description
The type constructor map is a shorthand for
map_type.
Synopsis
abstype map_type (key:t@ype, itm:t@ype+) = ptr
Synopsis
fun{key:t0p}
equal_key_key (x1: key, x2: key):<> bool
Description
This function is for testing whether two given map keys are equal.
Synopsis
fun{
} funmap_nil {key,itm:t0p}():<> map(key, itm)
Description
This function forms an empty map.
Synopsis
fun{
key,itm:t@ype
} funmap_size(map: map(key, INV(itm))):<> size_t
Description
This function returns the size of a given map. Its time complexity is
O(n).
Synopsis
fun{
key,itm:t0p
} funmap_search
(
map: map(key, INV(itm))
, key: key, res: &itm? >> opt(itm, b)
) : #[b:bool] bool(b)
Description
Given a map and a key, this function returns a boolean value to indicate
whether an item associated with the key has been found in the map. If found, the
item is stored in the third (call-by-reference) argument of the function.
The time complexity of funmap_search is O(log(n)).
Synopsis
fun{
key,itm:t0p
} funmap_search_opt
(map: map(key, INV(itm)), k0: key): Option_vt(itm)
Description
This function is the optional variant of the function funmap_search.
Synopsis
fun{
key,itm:t0p
} funmap_insert
(
map: &map(key, INV(itm)) >> _
, key: key, x0: itm, res: &itm? >> opt(itm, b)
) : #[b:bool] bool(b)
Synopsis
fun{
key,itm:t0p
} funmap_insert_opt
(
map: &map(key, INV(itm)) >> _, k0: key, x0: itm
) : Option_vt(itm)
Description
This function is the optional variant of the function funmap_insert.
Synopsis
fun{
key,itm:t0p
} funmap_insert_any
(map: &map(key, INV(itm)) >> _, k0: key, x0: itm): void
Description
Given a map, a key and an item, this function inserts the key-item pair
into the map. Note that the insertion is carried out even in the case where
the given key is already associated with some item in the map.
The time complexity of funmap_insert_any is O(n).
Synopsis
fun{
key,itm:t0p
} funmap_takeout (
&map(key, INV(itm)) >> _, k0: key, res: &itm? >> opt (itm, b)
) : #[b:bool] bool (b)
Synopsis
fun{
key,itm:t0p
} funmap_takeout_opt
(map: &map(key, INV(itm)) >> _, k0: key) : Option_vt (itm)
Synopsis
fun{
key,itm:t0p
} funmap_remove
(map: &map(key, INV(itm)) >> _, k0: key): bool
Synopsis
fun{
key,itm:t0p
} funmap_foreach(map: map(key, INV(itm))): void
Synopsis
fun
{key:t0p
;itm:t0p}
{env:vt0p}
funmap_foreach_env
(map: map(key, INV(itm)), env: &(env) >> _): void
Synopsis
fun
{key:t0p
;itm:t0p}
{env:vt0p}
funmap_foreach$fwork
(k: key, x: itm, env: &(env) >> _): void
Synopsis
fun{
key,itm:t0p
} funmap_listize
(map: map(key, INV(itm))):<!wrt> List0_vt(@(key,itm))
Synopsis
fun
{key:t0p
;itm:t0p}
{ki2:t0p}
funmap_flistize(map: map(key, INV(itm))): List0_vt(ki2)
Synopsis
fun
{key:t0p
;itm:t0p}
{ki2:t0p}
funmap_flistize$fopr(key, itm): ki2