'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 sig ... end
val t_of_sexp : (Base.Sexp.t ‑> 'a) ‑> Base.Sexp.t ‑> 'a t
val sexp_of_t : ('a ‑> Base.Sexp.t) ‑> 'a t ‑> Base.Sexp.t
val empty : _ t
val init_some : int ‑> f:(int ‑> 'a) ‑> 'a t
val init : int ‑> f:(int ‑> 'a option) ‑> 'a t
val length : _ t ‑> int
val get : 'a t ‑> int ‑> 'a option
get t i
returns the element number i
of array t
, raising if i
is outside the
range 0 to length t - 1
.
These can cause arbitrary behavior when used for an out-of-bounds array access.
val unsafe_get : 'a t ‑> int ‑> 'a option
val unsafe_get_some_exn : 'a t ‑> int ‑> 'a
val unsafe_is_some : _ t ‑> int ‑> bool
val set : 'a t ‑> int ‑> 'a option ‑> unit
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
.
val set_some : 'a t ‑> int ‑> 'a ‑> unit
val set_none : _ t ‑> int ‑> unit
Unsafe versions of set*
. Can cause arbitrary behaviour when used for an
out-of-bounds array access.
val unsafe_set : 'a t ‑> int ‑> 'a option ‑> unit
val unsafe_set_some : 'a t ‑> int ‑> 'a ‑> unit
val unsafe_set_none : _ t ‑> int ‑> unit
include Base.Blit.S1 with type a t := a t
val blit : ('a t, 'a t) Base__.Blit_intf.blit
val blito : ('a t, 'a t) Base__.Blit_intf.blito
val unsafe_blit : ('a t, 'a t) Base__.Blit_intf.blit
val sub : ('a t, 'a t) Base__.Blit_intf.sub
val subo : ('a t, 'a t) Base__.Blit_intf.subo