Module Incremental_kernel__.Balanced_reducer

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.

type 'a t
include sig ... end
val sexp_of_t : ('a ‑> Sexplib.Sexp.t) ‑> 'a t ‑> Sexplib.Sexp.t
include Core_kernel.Invariant.S1 with type t := a t
type 'a t
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 lenNones 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.