This package implements linear maps based on the randomized binary-search-tree (BST) structure.
Compared to balanced trees such as AVL-trees and red-black-trees, randomized binary-search-trees are relatively easier to implement. However, maps based on randomized BSTs are significantly less efficient than those based on balanced trees.
stadef map = map_vtype
absvtype
map_vtype (key:t@ype, itm:vt@ype+) = ptr
fun{key:t0p}
compare_key_key (x1: key, x2: key):<> int
fun{}
linmap_nil {key:t0p;itm:vt0p} ():<> map (key, itm)
fun{
} linmap_is_nil
{key:t0p;itm:vt0p} (map: !map (key, INV(itm))):<> bool
fun{
} linmap_isnot_nil
{key:t0p;itm:vt0p} (map: !map (key, INV(itm))):<> bool
fun{ key:t0p;itm:t0p } linmap_search ( !map (key, INV(itm)), key, res: &itm? >> opt (itm, b) ) : #[b:bool] bool(b) (*found*) // endfun
fun{
key:t0p;itm:vt0p
} linmap_search_ref
(map: !map (key, INV(itm)), k0: key): cPtr0 (itm)
fun{
key:t0p;itm:t0p
} linmap_search_opt
(map: !map (key, INV(itm)), k0: key): Option_vt (itm)
fun{ key:t0p;itm:vt0p } linmap_insert ( &map (key, INV(itm)) >> _, key, itm, res: &itm? >> opt (itm, b) ) : #[b:bool] bool(b) // endfun
fun{
key:t0p;itm:vt0p
} linmap_insert_opt
(map: &map (key, INV(itm)) >> _, k0: key, x0: itm): Option_vt (itm)
fun{ key:t0p;itm:vt0p } linmap_takeout ( &map (key, INV(itm)) >> _, key, res: &itm? >> opt (itm, b) ) : #[b:bool] bool(b) // endfun
fun{
key:t0p;itm:vt0p
} linmap_takeout_opt
(map: &map (key, INV(itm)) >> _, k0: key): Option_vt (itm)
fun{
key:t0p;itm:t0p
} linmap_remove (
map: &map (key, INV(itm)) >> _, k0: key): bool
fun{
key:t0p;itm:vt0p
} linmap_foreach (map: !map (key, INV(itm))): void
fun
{key:t0p
;itm:vt0p}
{env:vt0p}
linmap_foreach_env
(map: !map (key, INV(itm)), env: &(env) >> _): void
fun
{key:t0p
;itm:vt0p}
{env:vt0p}
linmap_foreach$fwork
(k: key, x: &itm >> _, env: &(env) >> _): void
fun{
key:t0p;itm:t0p
} linmap_free (map: map (key, INV(itm))):<!wrt> void
fun{
key:t0p;itm:vt0p
} linmap_freelin (map: map (key, INV(itm))):<!wrt> void
fun{
itm:vt0p
} linmap_freelin$clear (x: &itm >> _?):<!wrt> void
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
fun
{key:t0p
;itm:vt0p}
linmap_listize
(map: map (key, INV(itm))):<!wrt> List_vt @(key, itm)
fun
{key:t0p
;itm:vt0p}
{ki2:vt0p}
linmap_flistize (map: map (key, INV(itm))): List_vt (ki2)
Synopsis for [linmap_flistize$opr] is unavailable.
fun{
key,itm:t0p
} linmap_listize1
(map: !map (key, INV(itm))):<!wrt> List_vt @(key, itm)
fun{} linmap_randbst_initize (): void
fun{} linmap_randbst_random_m_n
{m,n:nat} (m: int m, n: int n): natLt (2)
This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. |