package base

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

Module Base.Uniform_arraySource

Same semantics as 'a Array.t, except it's guaranteed that the representation array is not tagged with Double_array_tag, the tag for float arrays.

This means it's safer to use in the presence of Obj.magic, but it's slower than normal Array if you use it with floats.

It can often be faster than Array if you use it with non-floats.

Sourcetype 'a t

See Base.Array for comments.

include Sexplib0.Sexpable.S1 with type 'a t := 'a t
Sourceval t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
Sourceval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
Sourceval compare__local : ('a -> 'a -> int) -> 'a t -> 'a t -> int
Sourceval invariant : _ t -> unit
Sourceval empty : _ t
Sourceval create : len:int -> 'a -> 'a t
Sourceval singleton : 'a -> 'a t
Sourceval init : int -> f:(int -> 'a) -> 'a t
Sourceval length : 'a t -> int
Sourceval get : 'a t -> int -> 'a
Sourceval unsafe_get : 'a t -> int -> 'a
Sourceval unsafe_get_local : 'a t -> int -> 'a
Sourceval set : 'a t -> int -> 'a -> unit
Sourceval unsafe_set : 'a t -> int -> 'a -> unit
Sourceval swap : _ t -> int -> int -> unit
Sourceval unsafe_set_omit_phys_equal_check : 'a t -> int -> 'a -> unit

unsafe_set_omit_phys_equal_check is like unsafe_set, except it doesn't do a phys_equal check to try to skip caml_modify. It is safe to call this even if the values are phys_equal.

Sourceval unsafe_set_with_caml_modify : 'a t -> int -> 'a -> unit

unsafe_set_with_caml_modify always calls caml_modify before setting and never gets the old value. This is like unsafe_set_omit_phys_equal_check except it doesn't check whether the old value and the value being set are integers to try to skip caml_modify.

Sourceval set_with_caml_modify : 'a t -> int -> 'a -> unit

Same as unsafe_set_with_caml_modify, but with bounds check.

Sourceval map : 'a t -> f:('a -> 'b) -> 'b t
Sourceval mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b t
Sourceval iter : 'a t -> f:('a -> unit) -> unit
Sourceval iteri : 'a t -> f:(int -> 'a -> unit) -> unit

Like iter, but the function is applied to the index of the element as first argument, and the element itself as second argument.

Sourceval fold : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc
Sourceval foldi : 'a t -> init:'acc -> f:(int -> 'acc -> 'a -> 'acc) -> 'acc
Sourceval unsafe_to_array_inplace__promise_not_a_float : 'a t -> 'a array

unsafe_to_array_inplace__promise_not_a_float converts from a t to an array in place. This function is unsafe if the underlying type is a float.

Sourceval of_array : 'a array -> 'a t

of_array and to_array return fresh arrays with the same contents rather than returning a reference to the underlying array.

Sourceval to_array : 'a t -> 'a array
Sourceval of_list : 'a list -> 'a t
Sourceval of_list_rev : 'a list -> 'a t
Sourceval to_list : 'a t -> 'a list
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
Sourceval copy : 'a t -> 'a t
Sourceval exists : 'a t -> f:('a -> bool) -> bool
Sourceval existsi : 'a t -> f:(int -> 'a -> bool) -> bool
Sourceval for_all : 'a t -> f:('a -> bool) -> bool
Sourceval for_alli : 'a t -> f:(int -> 'a -> bool) -> bool
Sourceval concat : 'a t list -> 'a t
Sourceval concat_map : 'a t -> f:('a -> 'b t) -> 'b t
Sourceval concat_mapi : 'a t -> f:(int -> 'a -> 'b t) -> 'b t
Sourceval partition_map : 'a t -> f:('a -> ('b, 'c) Either.t) -> 'b t * 'c t
Sourceval filter : 'a t -> f:('a -> bool) -> 'a t
Sourceval filteri : 'a t -> f:(int -> 'a -> bool) -> 'a t
Sourceval filter_map : 'a t -> f:('a -> 'b option) -> 'b t
Sourceval filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b t
Sourceval find : 'a t -> f:('a -> bool) -> 'a option
Sourceval findi : 'a t -> f:(int -> 'a -> bool) -> (int * 'a) option
Sourceval find_map : 'a t -> f:('a -> 'b option) -> 'b option
Sourceval find_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b option
Sourceval map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t

Functions with the 2 suffix raise an exception if the lengths of the two given arrays aren't the same.

Sourceval fold2_exn : 'a t -> 'b t -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc) -> 'acc
Sourceval min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
Sourceval max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
Sourceval sort : ?pos:int -> ?len:int -> 'a t -> compare:('a -> 'a -> int) -> unit

sort uses constant heap space.

To sort only part of the array, specify pos to be the index to start sorting from and len indicating how many elements to sort.

include Binary_searchable.S1 with type 'a t := 'a t
Sourceval binary_search_segmented : ?pos:int -> ?len:int -> 'a t -> segment_of:('a -> [ `Left | `Right ]) -> [ `Last_on_left | `First_on_right ] -> int option

Extra lowlevel and unsafe functions

Sourceval unsafe_create_uninitialized : len:int -> _ t

The behavior is undefined if you access an element before setting it.

Sourceval create_obj_array : len:int -> Obj.t t

New obj array filled with Obj.repr 0

Sourceval unsafe_set_assuming_currently_int : Obj.t t -> int -> Obj.t -> unit

unsafe_set_assuming_currently_int t i obj sets index i of t to obj, but only works correctly if the value there is an immediate, i.e. Stdlib.Obj.is_int (get t i). This precondition saves a dynamic check.

unsafe_set_int_assuming_currently_int is similar, except the value being set is an int.

unsafe_set_int is similar but does not assume anything about the target.

Sourceval unsafe_set_int_assuming_currently_int : Obj.t t -> int -> int -> unit
Sourceval unsafe_set_int : Obj.t t -> int -> int -> unit
Sourceval unsafe_clear_if_pointer : Obj.t t -> int -> unit

unsafe_clear_if_pointer t i prevents t.(i) from pointing to anything to prevent space leaks. It does this by setting t.(i) to Stdlib.Obj.repr 0. As a performance hack, it only does this when not (Stdlib.Obj.is_int t.(i)). It is an error to access the cleared index before setting it again.

OCaml

Innovation. Community. Security.