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).
  • map
  • map_type
  • equal_key_key
  • funmap_nil
  • funmap_size
  • funmap_search
  • funmap_search_opt
  • funmap_insert
  • funmap_insert_opt
  • funmap_insert_any
  • funmap_takeout
  • funmap_takeout_opt
  • funmap_remove
  • funmap_foreach
  • funmap_foreach_env
  • funmap_foreach$fwork
  • funmap_listize
  • funmap_flistize
  • funmap_flistize$fopr

  • map

    Synopsis

    typedef map(key:t0p, itm:t0p) = map_type(key, itm)

    Description

    The type constructor map is a shorthand for map_type.

    map_type

    Synopsis

    abstype map_type (key:t@ype, itm:t@ype+) = ptr

    equal_key_key

    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.

    funmap_nil

    Synopsis

    fun{
    } funmap_nil {key,itm:t0p}():<> map(key, itm)

    Description

    This function forms an empty map.

    funmap_size

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

    funmap_search

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

    funmap_search_opt

    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.

    funmap_insert

    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)

    funmap_insert_opt

    Synopsis

    fun{
    key,itm:t0p
    } funmap_insert_opt
    (
      map: &map(key, INV(itm)) >> _, k0: key, x0: itm
    ) : Option_vt(itm) // endfun

    Description

    This function is the optional variant of the function funmap_insert.

    funmap_insert_any

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

    funmap_takeout

    Synopsis

    fun{
    key,itm:t0p
    } funmap_takeout (
      &map(key, INV(itm)) >> _, k0: key, res: &itm? >> opt (itm, b)
    ) : #[b:bool] bool (b) // end-of-function

    funmap_takeout_opt

    Synopsis

    fun{
    key,itm:t0p
    } funmap_takeout_opt
      (map: &map(key, INV(itm)) >> _, k0: key) : Option_vt (itm)

    funmap_remove

    Synopsis

    fun{
    key,itm:t0p
    } funmap_remove
      (map: &map(key, INV(itm)) >> _, k0: key): bool

    funmap_foreach

    Synopsis

    fun{
    key,itm:t0p
    } funmap_foreach(map: map(key, INV(itm))): void

    funmap_foreach_env

    Synopsis

    fun
    {key:t0p
    ;itm:t0p}
    {env:vt0p}
    funmap_foreach_env
      (map: map(key, INV(itm)), env: &(env) >> _): void

    funmap_foreach$fwork

    Synopsis

    fun
    {key:t0p
    ;itm:t0p}
    {env:vt0p}
    funmap_foreach$fwork
      (k: key, x: itm, env: &(env) >> _): void

    funmap_listize

    Synopsis

    fun{
    key,itm:t0p
    } funmap_listize
      (map: map(key, INV(itm))):<!wrt> List0_vt(@(key,itm))

    funmap_flistize

    Synopsis

    fun
    {key:t0p
    ;itm:t0p}
    {ki2:t0p}
    funmap_flistize(map: map(key, INV(itm))): List0_vt(ki2)

    funmap_flistize$fopr

    Synopsis

    fun
    {key:t0p
    ;itm:t0p}
    {ki2:t0p}
    funmap_flistize$fopr(key, itm): ki2

    This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. SourceForge.net Logo