1(* Dynarray -- polymorphic dynamic arrays a la SML/NJ library *)
2
3signature Dynarray =
4sig
5
6type 'a array
7
8val array    : int * '_a -> '_a array
9val subArray : '_a array * int * int -> '_a array
10val fromList : '_a list * '_a -> '_a array
11val tabulate : int * (int -> '_a) * '_a -> '_a array
12val sub      : 'a array * int -> 'a
13val update   : '_a array * int * '_a  -> unit
14val default  : 'a array -> 'a
15val bound    : 'a array -> int
16
17end
18
19(*
20   ['ty array] is the type of one-dimensional, mutable, zero-based
21   unbounded arrays with elements of type 'ty.  Type 'ty array does
22   not admit equality.
23
24   [array(n, d)] returns a dynamic array, all of whose elements are
25   initialized to the default d.  The parameter n is used as a hint of the
26   upper bound on non-default elements.  Raises Size if n < 0.
27
28   [subArray(a, m, n)] returns a new array with the same default
29   value as a, and whose values in the range [0,n-m] equal the
30   values in a in the range [m,n].  Raises the exception Size if n < m.
31
32   [fromList (xs, d)] returns an array whose first elements are
33   those of [xs], and the rest are the default d.
34
35   [tabulate(n, f, d)] returns a new array whose first n elements
36   are f 0, f 1, ..., f (n-1), created from left to right, and whose
37   remaining elements are the default d.  Raises Size if n < 0.
38
39   [sub(a, i)] returns the i'th element of a, counting from 0.
40   Raises Subscript if i < 0.
41
42   [update(a, i, x)] destructively replaces the i'th element of a by x.
43   Raises Subscript if i < 0.
44
45   [default a] returns the default value of the array a.
46
47   [bound a] returns an upper bound on the indices of non-default values.
48*)
49