package core_kernel

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

This module extends Base.Option_array with bin_io.

type 'a t = 'a Base.Option_array.t
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1
val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1
val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1
val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1
val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writer
val bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.reader
val bin_t : ('a, 'a t) Bin_prot.Type_class.S1.t
include Ppx_sexp_conv_lib.Sexpable.S1 with type 'a t := 'a t
include module type of struct include Base.Option_array end with type 'a t := 'a t
include Base.Sexpable.S1 with type 'a t := 'a t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
val empty : _ t
val create : len:int -> _ t

Initially filled with all None

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.

val get_some_exn : 'a t -> int -> 'a

Raises if the element number i is None.

val is_none : _ t -> int -> bool

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

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

val unsafe_get : 'a t -> int -> 'a option
val 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 -> 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
val swap : _ t -> int -> int -> unit
val clear : _ t -> unit

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 -> 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 : src:'a t -> src_pos:int -> dst:'a t -> dst_pos:int -> len:int -> unit
val blito : src:'a t -> ?src_pos:int -> ?src_len:int -> dst:'a t -> ?dst_pos:int -> unit -> unit
val unsafe_blit : src:'a t -> src_pos:int -> dst:'a t -> dst_pos:int -> len:int -> unit
val sub : 'a t -> pos:int -> len:int -> 'a t
val subo : ?pos:int -> ?len:int -> 'a t -> 'a t
val copy : 'a t -> 'a t

Makes a (shallow) copy of the array.

OCaml

Innovation. Community. Security.