A module internal to Incremental. Users should see Incremental_intf.
A Balanced_reducer.t
is a mutable non-empty array that tracks the result of folding
an associative operation (reduce
) over the array as its elements change.
include sig ... end
val sexp_of_t : ('a ‑> Base.Sexp.t) ‑> 'a t ‑> Base.Sexp.t
include Core_kernel.Invariant.S1 with type a t := a t
val invariant : 'a Base__.Invariant_intf.inv ‑> 'a t Base__.Invariant_intf.inv
val create_exn : ?sexp_of_a:('a ‑> Core_kernel.Sexp.t) ‑> unit ‑> len:int ‑> reduce:('a ‑> 'a ‑> 'a) ‑> 'a t
create_exn ~len ~reduce
creates an array containing len
None
s and prepares an
incremental fold with reduce
. It raises if len < 1
.
val set_exn : 'a t ‑> int ‑> 'a ‑> unit
set_exn t i a
updates the value at index i
to Some a
. It raises if i
is out
of bounds.
val compute_exn : 'a t ‑> 'a
compute_exn t
computes the value of the fold. It raises if any values of the array
are None
.