module BC_CachedArray: sig endWARNING: Since values are only recomputed when necessary, and we cannot do a `dirty' check, data put in, or referenced by the cached arrays SHOULD NOT BE CHANGED.
A Weak Hash with a similar interface (automatic recalculation of the
value, when it is lost) might be more useful.
type 'a t
val init : int -> (int -> unit -> 'a) -> 'a tinit n f creates a cached array of size n, where
the ith element of the array will have value f i ().val make : int -> 'a -> 'a tmake n v makes a cached array of size n filled with value v.val get : 'a t -> int -> 'aval set : 'a t -> int -> (unit -> 'a) -> unitset arr i f sets the value at the ith position
to f ().val map : ('a -> 'b) -> 'a t -> 'b tval to_array : 'a t -> 'a arrayval of_array : 'a array -> 'a tval map_to_array : ('a -> 'b) -> 'a t -> 'b arrayval map_snapshot : ('a -> 'b) -> 'a t -> 'b tmap_snapshot f a creates a snapshot of a cached array.
That is, all values of f for each element a are calculated,
and then converted to a new cache array.
map_snapshot f a is the same as
of_array} (Array.map f (to_array a)) but
doesn't create the intermediate arrays.
Probably useful when the results of f are SMALL sized,
but may take a very LONG TIME to compute.
(but then again, you might want to use BC_CachedArray.map_to_array instead)val length : 'a t -> intval fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'aval init_matrix : dimx:int ->
dimy:int ->
(x:int -> y:int -> unit -> 'a) -> 'a t tval matrix_get : 'a t t -> x:int -> y:int -> 'aval matrix_set : 'a t t ->
x:int -> y:int -> (unit -> 'a) -> unitval map_matrix : ('a -> 'b) ->
'a t t -> 'b t t