home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Dynarray.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  1.6 KB  |  43 lines  |  [TEXT/Moml]

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