Commits

Anonymous committed 872fd91

Array.GrowingArray

Comments (0)

Files changed (1)

 
 
     (* GrowingArray -- module that reallocates array on demand.
-       Call [with_array requested_size user_func] to use this array.
-       Array will be resized to [default_size * 2^n] sizes on demand.
-       [user_func] may get array bigger than [requested_size].
-       After exitting [user_func] array will contain all items that
-       [user_func] left there, so they will be inaccessible for
-       garbage collection until [t 'a]-typed value is alive.
+       [request_array requested_size] will return array not shorter
+       than [requested_size].  Array will be resized to [default_size * 2^n]
+       sizes.  [request_array] may return array bigger than [requested_size],
+       not shorter.
      *)
 
     module GrowingArray
           'a (* default element's value *) ->
           t 'a
         ;
-        value with_array :
+        value request_array :
           int (* requested size *) ->
-          (array 'a -> 'b) ->
           t 'a ->
-          'b
+          array 'a
         ;
       end
      =
             }
         ;
 
-        value with_array requested_size user_func ga =
+        value request_array requested_size ga =
           if requested_size < 0 || requested_size > Sys.max_array_length
           then
             invalid_arg "Array.GrowingArray.with_array: requested_size"
                 )
             in
             let () = assert (Array.length arr >= requested_size) in
-              user_func arr
+            arr
         ;
 
       end