signature MLTON_VECTOR =
sig
val create: int -> {done: unit -> 'a vector,
sub: int -> 'a,
update: int * 'a -> unit}
val unfoldi: int * 'b * (int * 'b -> 'a * 'b) -> 'a vector * 'b
end
-
create n
initiates the construction a vector v of length
n
, returning functions to manipulate the vector. Thedone
function may be called to return the created vector; it is an error to calldone
before all entries have been initialized; it is an error to calldone
after having calleddone
. Thesub
function may be called to return an initialized vector entry; it is not an error to callsub
after having calleddone
. Theupdate
function may be called to initialize a vector entry; it is an error to callupdate
after having calleddone
. One must initialize vector entries in order from lowest to highest; that is, before callingupdate (i, x)
, one must have already calledupdate (j, x)
for allj
in[0, i)
. Thedone
,sub
, andupdate
functions are all constant-time operations. -
unfoldi (n, b, f)
constructs a vector v of length
n
, whose elements vi are determined by the equations b0 = b and (vi, bi+1) = f (i, bi).