package base
Module Base.Option_arraySource
'a Option_array.t is a compact representation of 'a option array: it avoids allocating heap objects representing Some x, usually representing them with x instead. It uses a special representation for None that's guaranteed to never collide with any representation of Some x.
include Indexed_container.Generic
with type ('a, _, _) t := 'a t
and type 'a elt := 'a option
include Container.Generic
with type ('a, _, _) t := 'a t
with type 'a elt := 'a option
val fold_until :
'a t ->
init:'acc ->
f:('acc -> 'a option -> ('acc, 'final) Container.Continue_or_stop.t) ->
finish:('acc -> 'final) ->
'finalval sum :
(module Container.Summable with type t = 'sum) ->
'a t ->
f:('a option -> 'sum) ->
'sumThese are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.
get t i returns the element number i of array t, raising if i is outside the range 0 to length t - 1.
Similar to get, but allocates result in the caller's stack region instead of heap.
These can cause arbitrary behavior when used for an out-of-bounds array access.
unsafe_get_some_exn t i is unsafe because it does not bounds check i. It does, however check whether the value at index i is none or some, and raises if it is none.
unsafe_get_some_assuming_some t i is unsafe both because it does not bounds check i and because it does not check whether the value at index i is none or some, assuming that it is some.
set t i x modifies array t in place, replacing element number i with x, raising if i is outside the range 0 to length t - 1.
map f [|a1; ...; an|] applies function f to a1, a2, ..., an, in order, and builds the option_array [|f a1; ...; f an|] with the results returned by f.
map_some t ~f is like map, but None elements always map to None and Some always map to Some.
Unsafe versions of set*. Can cause arbitrary behaviour when used for an out-of-bounds array access.