Initially filled with all None
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
Sourceval mem : 'a t -> 'a option -> equal:('a option -> 'a option -> bool) -> bool
Sourceval iter : 'a t -> f:('a option -> unit) -> unit
Sourceval fold : 'a t -> init:'acc -> f:('acc -> 'a option -> 'acc) -> 'acc
Sourceval exists : 'a t -> f:('a option -> bool) -> bool
Sourceval for_all : 'a t -> f:('a option -> bool) -> bool
Sourceval count : 'a t -> f:('a option -> bool) -> int
Sourceval find : 'a t -> f:('a option -> bool) -> 'a option option
Sourceval find_map : 'a t -> f:('a option -> 'b option) -> 'b option
Sourceval to_list : 'a t -> 'a option list
Sourceval min_elt :
'a t ->
compare:('a option -> 'a option -> int) ->
'a option option
Sourceval max_elt :
'a t ->
compare:('a option -> 'a option -> int) ->
'a option option
These are all like their equivalents in Container
except that an index starting at 0 is added as the first argument to f
.
Sourceval foldi : 'a t -> init:_ -> f:(int -> _ -> 'a option -> _) -> _
Sourceval iteri : 'a t -> f:(int -> 'a option -> unit) -> unit
Sourceval existsi : 'a t -> f:(int -> 'a option -> bool) -> bool
Sourceval for_alli : 'a t -> f:(int -> 'a option -> bool) -> bool
Sourceval counti : 'a t -> f:(int -> 'a option -> bool) -> int
Sourceval findi : 'a t -> f:(int -> 'a option -> bool) -> (int * 'a option) option
Sourceval find_mapi : 'a t -> f:(int -> 'a option -> 'b option) -> 'b option
Sourceval init_some : int -> f:(int -> 'a) -> 'a t
Sourceval init : int -> f:(int -> 'a option) -> 'a t
Sourceval of_array : 'a option array -> 'a t
Sourceval of_array_some : 'a array -> 'a t
Sourceval 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
.
Sourceval get_local : 'a t -> int -> 'a option
Similar to get
, but allocates result in the caller's stack region instead of heap.
Sourceval get_some_exn : 'a t -> int -> 'a
Raises if the element number i
is None
.
Sourceval is_none : _ t -> int -> bool
is_none t i = Option.is_none (get t i)
Sourceval is_some : _ t -> int -> bool
is_some t i = Option.is_some (get t i)
These can cause arbitrary behavior when used for an out-of-bounds array access.
Sourceval unsafe_get : 'a t -> int -> 'a option
Sourceval 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.
Sourceval 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.
Sourceval unsafe_is_some : _ t -> int -> bool
Sourceval 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
.
Sourceval set_some : 'a t -> int -> 'a -> unit
Sourceval set_none : _ t -> int -> unit
Sourceval swap : _ t -> int -> int -> unit
Replaces all the elements of the array with None
.
Sourceval 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
.
Sourceval 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.
Sourceval unsafe_set : 'a t -> int -> 'a option -> unit
Sourceval unsafe_set_some : 'a t -> int -> 'a -> unit
Sourceval unsafe_set_none : _ t -> int -> unit
include Blit.S1 with type 'a t := 'a t
Sourceval blit :
src:'a t ->
src_pos:int ->
dst:'a t ->
dst_pos:int ->
len:int ->
unit
Sourceval blito :
src:'a t ->
?src_pos:int ->
?src_len:int ->
dst:'a t ->
?dst_pos:int ->
unit ->
unit
Sourceval unsafe_blit :
src:'a t ->
src_pos:int ->
dst:'a t ->
dst_pos:int ->
len:int ->
unit
Sourceval sub : 'a t -> pos:int -> len:int -> 'a t
Sourceval subo : ?pos:int -> ?len:int -> 'a t -> 'a t
Makes a (shallow) copy of the array.