This package implements array-based linear stacks.
stadef stkarray = stkarray_vtype
vtypedef stkarray (a:vt0p) = [m,n:int] stkarray_vtype (a, m, n)
absvtype
stkarray_vtype (a:vt@ype+, m:int, n:int) = ptr
fun{a:vt0p}
stkarray_make_cap
{m:int} (cap: size_t(m)):<!wrt> stkarray (a, m, 0)
fun
stkarray_make_ngc__tsz
{a:vt0p}
{l:addr}{m:int}
(
stkarray_tsize? @ l
| ptr(l), arrayptr(a?, m), size_t(m), sizeof_t(a)
) :<!wrt> (mfree_ngc_v (l) | stkarray (a, m, 0)) = "mac#%"
fun
stkarray_free_nil
{a:vt0p}{m:int}
(stk: stkarray (a, m, 0)):<!wrt> void = "mac#%"
fun
stkarray_is_nil
{a:vt0p}{m,n:int}
(stk: !stkarray (INV(a), m, n)):<> bool (n==0) = "mac#%"
fun
stkarray_isnot_nil
{a:vt0p}{m,n:int}
(stk: !stkarray (INV(a), m, n)):<> bool (n > 0) = "mac#%"
fun
stkarray_is_full
{a:vt0p}{m,n:int}
(stk: !stkarray (INV(a), m, n)):<> bool (m==n) = "mac#%"
fun
stkarray_isnot_full
{a:vt0p}{m,n:int}
(stk: !stkarray (INV(a), m, n)):<> bool (m > n) = "mac#%"
fun{a:vt0p}
stkarray_get_size
{m,n:int} (stk: !stkarray (INV(a), m, n)):<> size_t(n)
fun{a:vt0p}
stkarray_get_capacity
{m,n:int} (stk: !stkarray (INV(a), m, n)):<> size_t(m)
fun{a:vt0p} stkarray_insert {m,n:int | m > n} ( stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n+1), x0: a ) :<!wrt> void // endfun
fun{a:vt0p}
stkarray_insert_opt
(stk: !stkarray (INV(a)) >> _, x0: a):<!wrt> Option_vt (a)
fun{a:vt0p} stkarray_takeout {m,n:int | n > 0} ( stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n-1) ) :<!wrt> (a) // endfun
fun{a:vt0p}
stkarray_takeout_opt
(stk: !stkarray (INV(a)) >> _):<!wrt> Option_vt (a)
fun{a:vt0p}
fprint_stkarray
(out: FILEref, stk: !stkarray (INV(a))): void
overload fprint with fprint_stkarray
overload fprint with fprint_stkarray_sep
This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. |