This package implements linear queues based on the singly-linked list structure. Such queues, often referred to as qlist-objects, can be employed to accumulate items that need to be returned in a list in which the items appear in the same order as they are accumulated.
vtypedef qlist(a:vt0p, n:int) = qlist_vtype(a, n)
vtypedef qlist(a:vt0p) = [n:int] qlist_vtype(a, n)
absvtype
qlist_vtype(a:vt@ype+, n:int) = ptr
vtypedef qlist0(a:vt0p) = [n:int | n >= 0] qlist(a, n)
Synopsis for [qlist1] is unavailable.
fun{}
qlist_make_nil{a:vt0p}():<!wrt> qlist(a, 0)
fun{}
qlist_free_nil{a:vt0p}(qlist(a, 0)):<!wrt> void
fun{a:vt0p}
qlist_is_nil
{n:int} (q0: !qlist(a, n)):<> bool (n == 0)
fun{a:vt0p}
qlist_isnot_nil
{n:int} (q0: !qlist(INV(a), n)):<> bool (n > 0)
fun
{a:vt0p}
qlist_length
{n:int}(q0: !qlist(INV(a), n)):<> int(n)
fun{a:vt0p} qlist_insert{n:int} ( q0: !qlist(INV(a), n) >> qlist(a, n+1), x: a ) :<!wrt> void // end of [qlist_insert]
fun{a:vt0p} qlist_takeout{n:pos} ( q0: !qlist(INV(a), n) >> qlist(a, n-1) ) :<!wrt> (a) // end-of-function
fun{a:vt0p}
qlist_takeout_opt
(q0: !qlist(INV(a)) >> _):<!wrt> Option_vt(a)
fun{}
qlist_takeout_list
{a:vt0p}{n:int}
(q0: !qlist(INV(a), n) >> qlist(a, 0)):<!wrt> list_vt(a, n)
// staload "libats/SATS/qlist.sats" // fun{ a:t0p } list_copy {n:int} ( xs: list (a, n) ) : list_vt (a, n) = let // fun loop {i,j:int} ( xs: list (a, i), pq: qlist (a, j) ) : list_vt (a, i+j) = let in // case+ xs of | list_cons (x, xs) => let val () = qlist_insert (pq, x) in loop (xs, pq) end // end of [list_cons] | list_nil () => let val res = qlist_takeout_list (pq) val () = qlist_free_nil (pq) in res end // end of [list_nil] // end // end of [loop] // in loop (xs, qlist_make_nil ()) end // end of [list_copy]
fun
{a:vt0p}
{env:vt0p}
qlist_foreach$cont (x: &a, env: &env): bool
fun
{a:vt0p}
{env:vt0p}
qlist_foreach$fwork (x: &a >> _, env: &(env) >> _): void
fun
{a:vt0p}
qlist_foreach (q: !qlist(INV(a))): void
fun
{a:vt0p}
{env:vt0p}
qlist_foreach_env
(q: !qlist(INV(a)), env: &(env) >> _): void
abst@ype qstruct_tsize = $extype"atslib_qlist_qstruct" stadef qstruct = qstruct_tsize absvt@ype qstruct_vt0ype (a:vt@ype+, n:int) = qstruct_tsize stadef qstruct = qstruct_vt0ype
The abstract type qstruct_tsize is primarily needed for allocating a variable in the calling frame of a function to store a qstruct-value.
Given a type T and an integer N, the abstract type qstruct_vt0ype(T, N) is for an unboxed queue containing N elements of type T.
fun{}
qstruct_initize
{a:vt0p}
(q0: &qstruct? >> qstruct(a, 0)):<!wrt> void
praxi
qstruct_uninitize
{a:vt0p}
( q0: &qstruct(a, 0) >> qstruct? ):<prf> void
praxi qstruct_objfize {a:vt0p} {l:addr}{n:int} ( pf: qstruct(INV(a), n) @ l | p: !ptrlin l >> qlist(a, n) ) :<prf> mfree_ngc_v (l) // endfun
praxi qstruct_unobjfize {a:vt0p} {l:addr}{n:int} ( pf: mfree_ngc_v(l) | p: ptr l, q: !qlist(INV(a), n) >> ptrlin l ) :<prf> qstruct(a, n) @ l // endfun
fun{a:vt0p}
qstruct_insert{n:int}
(q: &qstruct(INV(a), n) >> qstruct(a, n+1), x: a):<!wrt> void
fun{a:vt0p}
qstruct_takeout{n:pos}
(q: &qstruct(INV(a), n) >> qstruct(a, n-1)):<!wrt> (a)
fun{}
qstruct_takeout_list
{a:vt0p}{n:int}
(q: &qstruct(INV(a), n) >> qstruct(a, 0)):<!wrt> list_vt(a, n)
absvtype
qlist_node_vtype(a:vt@ype+, l:addr) = ptr
stadef mynode = qlist_node_vtype
vtypedef mynode(a) = [l:addr] mynode(a, l)
vtypedef mynode0(a) = [l:addr | l >= null] mynode(a, l)
vtypedef mynode1(a) = [l:addr | l > null] mynode(a, l)
castfn
mynode2ptr
{a:vt0p}
{l:addr}
(nx: !mynode(INV(a), l)):<> ptr(l)
praxi
mynode_free_null{a:vt0p}(nx: mynode(a, null)): void
fun{a:vt0p}
mynode_make_elt(x: a):<!wrt> mynode1(a)
fun{a:vt0p}
mynode_getref_elt(nx: !mynode1(INV(a))):<> cPtr1(a)
fun{a:vt0p}
mynode_free_elt
(nx: mynode1(INV(a)), res: &(a?) >> a):<!wrt> void
fun{a:vt0p}
mynode_getfree_elt(node: mynode1(INV(a))):<!wrt> (a)
fun{a:vt0p} qlist_insert_ngc (*last*) {n:int} ( q0: !qlist(INV(a), n) >> qlist(a, n+1), nx: mynode1(a) ) :<!wrt> void // end of [qlist_insert_ngc]
fun{a:vt0p}
qlist_takeout_ngc (*first*)
{n:int | n > 0}
(q0: !qlist(INV(a), n) >> qlist(a, n-1)):<!wrt> mynode1(a)
overload iseqz with qlist_is_nil
overload isneqz with qlist_isnot_nil
overload length with qlist_length
overload fprint with fprint_qlist
overload fprint with fprint_qlist_sep
This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. |