ATSLIB/libats/linmap_list

This package implements linear maps based on the singly-linked list structure. Note that this is only practical for maps of short size (e.g., containing only a few dozens keys).


  • map
  • map_vtype
  • equal_key_key
  • compare_key_key
  • linmap_nil
  • linmap_make_nil
  • linmap_is_nil
  • linmap_isnot_nil
  • linmap_size
  • linmap_search
  • linmap_search_ref
  • linmap_search_opt
  • linmap_insert
  • linmap_insert_opt
  • linmap_insert_any
  • linmap_takeout
  • linmap_takeout_opt
  • linmap_remove
  • linmap_foreach
  • linmap_foreach_env
  • linmap_foreach$fwork
  • linmap_free
  • linmap_freelin
  • linmap_freelin$clear
  • linmap_free_ifnil
  • linmap_listize
  • linmap_flistize
  • linmap_flistize$fopr
  • linmap_listize1
  • linmap_node_vtype
  • mynode
  • mynode0
  • mynode1
  • mynode_make_keyitm
  • mynode_get_key
  • mynode_getref_itm
  • mynode_getfree_itm
  • mynode_free_keyitm
  • linmap_search_ngc
  • linmap_insert_ngc
  • linmap_takeout_ngc

  • map

    Synopsis

    stadef map = map_vtype

    Description

    The type constructor map is a shorthand for map_vtype.

    map_vtype

    Synopsis

    absvtype
    map_vtype (key:t@ype, itm:vt@ype+) = ptr

    Description

    Given a type K and a viewtype T, the abstract viewtype map_vtype(K, T) is for a map storing links from keys of the type K to items of the viewtype T. Note that map_vtype is co-variant in its second argument.

    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.

    compare_key_key

    Synopsis

    fun{key:t0p}
    compare_key_key (x1: key, x2: key):<> int

    Description

    This function is not available.

    linmap_nil

    Synopsis

    fun{}
    linmap_nil {key:t0p;itm:vt0p} ():<> map (key, itm)

    Description

    This function creates an empty map.

    linmap_make_nil

    Synopsis

    fun{}
    linmap_make_nil {key:t0p;itm:vt0p} ():<!wrt> map (key, itm)

    Description

    This function is the same as linmap_nil.

    linmap_is_nil

    Synopsis

    fun{
    } linmap_is_nil
      {key:t0p;itm:vt0p} (map: !map (key, INV(itm))):<> bool

    Description

    This function tests whether a given map is empty.

    linmap_isnot_nil

    Synopsis

    fun{
    } linmap_isnot_nil
      {key:t0p;itm:vt0p} (map: !map (key, INV(itm))):<> bool

    Description

    This function tests whether a given map is non-empty.

    linmap_size

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_size (map: !map (key, INV(itm))):<> size_t

    linmap_search

    Synopsis

    fun{
    key:t0p;itm:t0p
    } linmap_search
    (
      !map (key, INV(itm)), key, res: &itm? >> opt (itm, b)
    ) : #[b:bool] bool(b) (*found*) // endfun

    linmap_search_ref

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_search_ref
      (map: !map (key, INV(itm)), k0: key): cPtr0 (itm)

    linmap_search_opt

    Synopsis

    fun{
    key:t0p;itm:t0p
    } linmap_search_opt
      (map: !map (key, INV(itm)), k0: key): Option_vt (itm)

    linmap_insert

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_insert
    (
      &map (key, INV(itm)) >> _, key, itm, res: &itm? >> opt (itm, b)
    ) : #[b:bool] bool(b) // endfun

    Description

    This function is not avaiable.

    linmap_insert_opt

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_insert_opt
      (map: &map (key, INV(itm)) >> _, k0: key, x0: itm): Option_vt (itm)

    Description

    This function is not avaiable.

    linmap_insert_any

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_insert_any
      (map: &map (key, INV(itm)) >> _, k0: key, x0: itm): void

    Description

    This function inserts a link from [k0] to [x0] into a given map [map]. In the case where the key [k0] is already associated with some item in the given map, the original link is shadowed by the newly inserted link.

    linmap_takeout

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_takeout
    (
      &map (key, INV(itm)) >> _, key, res: &itm? >> opt (itm, b)
    ) : #[b:bool] bool(b) // endfun

    linmap_takeout_opt

    Synopsis

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

    linmap_remove

    Synopsis

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

    linmap_foreach

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_foreach (map: !map (key, INV(itm))): void

    linmap_foreach_env

    Synopsis

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

    linmap_foreach$fwork

    Synopsis

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

    linmap_free

    Synopsis

    fun{
    key:t0p;itm:t0p
    } linmap_free (map: map (key, INV(itm))):<!wrt> void

    Description

    This function frees a given map containing only non-linear items.

    linmap_freelin

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_freelin (map: map (key, INV(itm))):<!wrt> void

    linmap_freelin$clear

    Synopsis

    fun{
    itm:vt0p
    } linmap_freelin$clear (x: &itm >> _?):<!wrt> void

    linmap_free_ifnil

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_free_ifnil
    (
      map: !map (key, INV(itm)) >> opt (map (key, itm), b)
    ) :<!wrt> #[b:bool] bool(b) (*~freed*) // endfun

    Description

    Given a map, this function frees it and returns false if the map is empty. Otherwise, the function keeps the map and returns true.

    linmap_listize

    Synopsis

    fun
    {key:t0p
    ;itm:vt0p}
    linmap_listize
      (map: map (key, INV(itm))):<!wrt> List_vt @(key, itm)

    linmap_flistize

    Synopsis

    fun
    {key:t0p
    ;itm:vt0p}
    {ki2:vt0p}
    linmap_flistize (map: map (key, INV(itm))): List_vt (ki2)

    linmap_flistize$fopr

    Synopsis

    fun
    {key:t0p
    ;itm:vt0p}
    {ki2:vt0p}
    linmap_flistize$fopr (k: key, x: itm): ki2

    linmap_listize1

    Synopsis

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

    linmap_node_vtype

    Synopsis

    absvtype
    linmap_node_vtype
      (key:t@ype, itm:vt@ype+, l:addr) = ptr(l)

    mynode

    Synopsis

    stadef mynode = linmap_node_vtype // HX: local shorthand
    vtypedef
    mynode (key:t0p, itm:vt0p) = [l:addr] mynode (key, itm, l)

    mynode0

    Synopsis

    vtypedef
    mynode0 (key:t0p, itm:vt0p) = [l:addr | l >= null] mynode (key, itm, l)

    mynode1

    Synopsis

    vtypedef
    mynode1 (key:t0p, itm:vt0p) = [l:addr | l >  null] mynode (key, itm, l)

    mynode_make_keyitm

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } mynode_make_keyitm
      (k: key, x: itm):<!wrt> mynode1 (key, itm)

    mynode_get_key

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } mynode_get_key
      (nx: !mynode1 (key, INV(itm))):<> key

    mynode_getref_itm

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } mynode_getref_itm
      (nx: !mynode1 (key, INV(itm))):<> cPtr1 (itm)

    mynode_getfree_itm

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } mynode_getfree_itm (nx: mynode1 (key, INV(itm))):<!wrt> itm

    mynode_free_keyitm

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } mynode_free_keyitm
    (
      nx: mynode1(key, INV(itm)), k0: &key? >> _, x0: &itm? >> _
    ) :<!wrt> void // end of [mynode_free_keyitm]

    linmap_search_ngc

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_search_ngc
      (map: !map (key, INV(itm)), k0: key): Ptr0(*mynode*)

    linmap_insert_ngc

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_insert_ngc
    (
      map: &map (key, INV(itm)) >> _, nx: mynode1 (key, itm)
    ) : mynode0 (key, itm) // endfun

    linmap_takeout_ngc

    Synopsis

    fun{
    key:t0p;itm:vt0p
    } linmap_takeout_ngc
      (map: &map (key, INV(itm)) >> _, k0: key): mynode0 (key, itm)

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