package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

'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.

type 'a t
include sig ... end
val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
val bin_read_t : 'a Bin_prot.Read.reader -> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader -> (Base.Int.t -> 'a t) Bin_prot.Read.reader
val bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Write.writer -> 'a t Bin_prot.Write.writer
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val empty : _ t
val create : len:Base.Int.t -> _ t

Initially filled with all None

val init_some : Base.Int.t -> f:(Base.Int.t -> 'a) -> 'a t
val init : Base.Int.t -> f:(Base.Int.t -> 'a Base.Option.t) -> 'a t
val length : _ t -> Base.Int.t
val get : 'a t -> Base.Int.t -> 'a Base.Option.t

get 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 -> Base.Int.t -> 'a

Raises if the element number i is None.

val is_none : _ t -> Base.Int.t -> Base.Bool.t

is_none t i = Option.is_none (get t i)

val is_some : _ t -> Base.Int.t -> Base.Bool.t

is_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 -> Base.Int.t -> 'a Base.Option.t
val unsafe_get_some_exn : 'a t -> Base.Int.t -> 'a
val unsafe_is_some : _ t -> Base.Int.t -> Base.Bool.t
val set : 'a t -> Base.Int.t -> 'a Base.Option.t -> Base.Unit.t

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 -> Base.Int.t -> 'a -> Base.Unit.t
val set_none : _ t -> Base.Int.t -> Base.Unit.t
val clear : _ t -> Base.Unit.t

Replaces all the elements of the array with None.

Unsafe versions of set*. Can cause arbitrary behaviour when used for an out-of-bounds array access.

val unsafe_set : 'a t -> Base.Int.t -> 'a Base.Option.t -> Base.Unit.t
val unsafe_set_some : 'a t -> Base.Int.t -> 'a -> Base.Unit.t
val unsafe_set_none : _ t -> Base.Int.t -> Base.Unit.t
include 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
val copy : 'a t -> 'a t

Makes a (shallow) copy of the array.

OCaml

Innovation. Community. Security.