Module Base.Option_array '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.
val create : len :int -> _ t Initially filled with all None
include Indexed_container.Generic
with type 'a t := 'a t
and type 'a elt := 'a optioninclude Container.Generic with type 'a t := 'a t with type 'a elt := 'a optionval is_empty : _ t -> boolval iter : 'a t -> f :('a option -> unit) -> unitval fold : 'a t -> init :'accum -> f :('accum -> 'a option -> 'accum ) -> 'accum val fold_result :
'a t ->
init :'accum ->
f :('accum -> 'a option -> ('accum , 'e ) Result.t ) ->
('accum , 'e ) Result.t val fold_until :
'a t ->
init :'accum ->
f :('accum -> 'a option -> ('accum , 'final ) Container.Continue_or_stop.t ) ->
finish :('accum -> 'final ) ->
'final val exists : 'a t -> f :('a option -> bool) -> boolval for_all : 'a t -> f :('a option -> bool) -> boolval count : 'a t -> f :('a option -> bool) -> intval find : 'a t -> f :('a option -> bool) -> 'a option optionval find_map : 'a t -> f :('a option -> 'b option ) -> 'b optionval to_list : 'a t -> 'a option listval min_elt :
'a t ->
compare :('a option -> 'a option -> int) ->
'a option optionval max_elt :
'a t ->
compare :('a option -> 'a option -> int) ->
'a option optionThese are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.
val foldi : 'a t -> init :_ -> f :(int -> _ -> 'a option -> _ ) -> _ val iteri : 'a t -> f :(int -> 'a option -> unit) -> unitval existsi : 'a t -> f :(int -> 'a option -> bool) -> boolval for_alli : 'a t -> f :(int -> 'a option -> bool) -> boolval counti : 'a t -> f :(int -> 'a option -> bool) -> intval findi : 'a t -> f :(int -> 'a option -> bool) -> (int * 'a option ) optionval find_mapi : 'a t -> f :(int -> 'a option -> 'b option ) -> 'b optionval init_some : int -> f :(int -> 'a ) -> 'a t val init : int -> f :(int -> 'a option ) -> 'a t val of_array : 'a option array -> 'a t val of_array_some : 'a array -> 'a t val to_array : 'a t -> 'a option Array.t val get : 'a t -> int -> 'a optionget t i returns the element number i of array t, raising if i is outside the range 0 to length t - 1.
val get_some_exn : 'a t -> int -> 'a Raises if the element number i is None.
val is_none : _ t -> int -> boolis_none t i = Option.is_none (get t i)
val is_some : _ t -> int -> boolis_some t i = Option.is_some (get t i)
These can cause arbitrary behavior when used for an out-of-bounds array access.
val unsafe_get : 'a t -> int -> 'a optionval unsafe_get_some_exn : 'a t -> int -> 'a 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.
val unsafe_get_some_assuming_some : 'a t -> int -> 'a 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.
val unsafe_is_some : _ t -> int -> boolval set : 'a t -> int -> 'a option -> unitset 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 -> unitval set_none : _ t -> int -> unitval swap : _ t -> int -> int -> unitReplaces all the elements of the array with None.
val map : 'a t -> f :('a option -> 'b option ) -> 'b t 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.
val map_some : 'a t -> f :('a -> 'b ) -> 'b t 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.
val unsafe_set : 'a t -> int -> 'a option -> unitval unsafe_set_some : 'a t -> int -> 'a -> unitval unsafe_set_none : _ t -> int -> unitinclude Blit.S1 with type 'a t := 'a t val blit :
src :'a t ->
src_pos :int ->
dst :'a t ->
dst_pos :int ->
len :int ->
unitval blito :
src :'a t ->
?src_pos :int ->
?src_len :int ->
dst :'a t ->
?dst_pos :int ->
unit ->
unitval unsafe_blit :
src :'a t ->
src_pos :int ->
dst :'a t ->
dst_pos :int ->
len :int ->
unitval sub : 'a t -> pos :int -> len :int -> 'a t val subo : ?pos :int -> ?len :int -> 'a t -> 'a t Makes a (shallow) copy of the array.