jon.recoil.org

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 : value_or_null) t

See Base.Array for comments.

Sourceval sexp_of_t : ('a : value_or_null). (('a : value_or_null) -> Sexplib0.Sexp.t) -> ('a : value_or_null) Base.Uniform_array.t -> Sexplib0.Sexp.t
Sourceval t_of_sexp : ('a : value_or_null). (Sexplib0.Sexp.t -> ('a : value_or_null)) -> Sexplib0.Sexp.t -> ('a : value_or_null) Base.Uniform_array.t
Sourceval t_sexp_grammar : ('a : value_or_null). ('a : value_or_null) Sexplib0.Sexp_grammar.t -> ('a : value_or_null) Base.Uniform_array.t Sexplib0.Sexp_grammar.t @@ portable
Sourceval compare : ('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> int) -> ('a : value_or_null) Base.Uniform_array.t -> ('a : value_or_null) Base.Uniform_array.t -> int
Sourceval compare__local : ('a : value_or_null). (('a : value_or_null) @ local -> ('a : value_or_null) @ local -> int) -> ('a : value_or_null) Base.Uniform_array.t @ local -> ('a : value_or_null) Base.Uniform_array.t @ local -> int
Sourceval invariant : ('a : value_or_null). 'a Base.Uniform_array.t -> unit @@ portable
Sourceval empty : ('a : value_or_null). 'a Base.Uniform_array.t @@ portable
Sourceval get_empty : unit -> _ Base.Uniform_array.t @@ portable

For obtaining uncontended access to empty from a portable function.

Sourceval create : ('a : value_or_null). len:int -> 'a -> 'a Base.Uniform_array.t @@ portable
Sourceval singleton : ('a : value_or_null). 'a -> 'a Base.Uniform_array.t @@ portable
Sourceval init : ('a : value_or_null). int -> f:(int -> 'a) @ local -> 'a Base.Uniform_array.t @@ portable
Sourceval length : ('a : value_or_null). 'a Base.Uniform_array.t @ local contended -> int @@ portable
Sourceval get : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a @@ portable
Sourceval unsafe_get : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a @@ portable
Sourceval set : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a -> unit @@ portable
Sourceval unsafe_set : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a -> unit @@ portable
Sourceval swap : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> int -> unit @@ portable
Sourceval unsafe_set_omit_phys_equal_check : ('a : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a -> unit @@ portable

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 : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a -> unit @@ portable

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 : value_or_null). 'a Base.Uniform_array.t @ local -> int -> 'a -> unit @@ portable

Same as unsafe_set_with_caml_modify, but with bounds check.

Sourceval map : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:('a -> 'b) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval mapi : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> 'b) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval iter : ('a : value_or_null). 'a Base.Uniform_array.t -> f:('a -> unit) @ local -> unit @@ portable
Sourceval iteri : ('a : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> unit) @ local -> unit @@ portable

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 : value_or_null) 'acc. 'a Base.Uniform_array.t -> init:'acc -> f:('acc -> 'a -> 'acc) @ local -> 'acc @@ portable
Sourceval foldi : ('a : value_or_null) 'acc. 'a Base.Uniform_array.t -> init:'acc -> f:(int -> 'acc -> 'a -> 'acc) @ local -> 'acc @@ portable
Sourceval unsafe_to_array_inplace__promise_not_a_float : 'a Base.Uniform_array.t -> 'a array @@ portable

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 Base.Uniform_array.t @@ portable

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 Base.Uniform_array.t -> 'a array @@ portable
Sourceval of_list : ('a : value_or_null). 'a list -> 'a Base.Uniform_array.t @@ portable
Sourceval of_list_rev : ('a : value_or_null). 'a list -> 'a Base.Uniform_array.t @@ portable
Sourceval to_list : ('a : value_or_null). 'a Base.Uniform_array.t -> 'a list @@ portable
include Base.Blit.S1 with type 'a t := 'a Base.Uniform_array.t
val blit : src:'a Base.Uniform_array.t @ local -> src_pos:int -> dst:'a Base.Uniform_array.t @ local -> dst_pos:int -> len:int -> unit
val blito : src:'a Base.Uniform_array.t @ local -> ?src_pos:int -> ?src_len:int -> dst:'a Base.Uniform_array.t @ local -> ?dst_pos:int -> unit -> unit
val unsafe_blit : src:'a Base.Uniform_array.t @ local -> src_pos:int -> dst:'a Base.Uniform_array.t @ local -> dst_pos:int -> len:int -> unit
val sub : 'a Base.Uniform_array.t @ local -> pos:int -> len:int -> 'a Base.Uniform_array.t
val subo : ?pos:int -> ?len:int -> 'a Base.Uniform_array.t @ local -> 'a Base.Uniform_array.t
Sourceval copy : ('a : value_or_null). 'a Base.Uniform_array.t -> 'a Base.Uniform_array.t @@ portable
Sourceval exists : ('a : value_or_null). 'a Base.Uniform_array.t -> f:('a -> bool) @ local -> bool @@ portable
Sourceval existsi : ('a : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> bool) @ local -> bool @@ portable
Sourceval for_all : ('a : value_or_null). 'a Base.Uniform_array.t -> f:('a -> bool) @ local -> bool @@ portable
Sourceval for_alli : ('a : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> bool) @ local -> bool @@ portable
Sourceval concat : ('a : value_or_null). 'a Base.Uniform_array.t list -> 'a Base.Uniform_array.t @@ portable
Sourceval concat_map : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:('a -> 'b Base.Uniform_array.t) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval concat_mapi : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> 'b Base.Uniform_array.t) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval partition_map : ('a : value_or_null) 'b 'c. 'a Base.Uniform_array.t -> f:('a -> ('b, 'c) Base.Either.t) @ local -> 'b Base.Uniform_array.t * 'c Base.Uniform_array.t @@ portable
Sourceval filter : ('a : value_or_null). 'a Base.Uniform_array.t -> f:('a -> bool) @ local -> 'a Base.Uniform_array.t @@ portable
Sourceval filteri : ('a : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> bool) @ local -> 'a Base.Uniform_array.t @@ portable
Sourceval filter_map : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:('a -> 'b option) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval filter_mapi : ('a : value_or_null) ('b : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> 'b option) @ local -> 'b Base.Uniform_array.t @@ portable
Sourceval find : ('a : value_or_null). 'a Base.Uniform_array.t -> f:('a -> bool) @ local -> 'a option @@ portable
Sourceval findi : ('a : value_or_null). 'a Base.Uniform_array.t -> f:(int -> 'a -> bool) @ local -> (int * 'a) option @@ portable
Sourceval find_map : ('a : value_or_null) 'b. 'a Base.Uniform_array.t -> f:('a -> 'b option) @ local -> 'b option @@ portable
Sourceval find_mapi : ('a : value_or_null) 'b. 'a Base.Uniform_array.t -> f:(int -> 'a -> 'b option) @ local -> 'b option @@ portable
Sourceval map2_exn : ('a : value_or_null) ('b : value_or_null) ('c : value_or_null). 'a Base.Uniform_array.t -> 'b Base.Uniform_array.t -> f:('a -> 'b -> 'c) @ local -> 'c Base.Uniform_array.t @@ portable

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

Sourceval fold2_exn : ('a : value_or_null) ('b : value_or_null) 'acc. 'a Base.Uniform_array.t -> 'b Base.Uniform_array.t -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc) @ local -> 'acc @@ portable
Sourceval min_elt : 'a Base.Uniform_array.t -> compare:('a -> 'a -> int) @ local -> 'a option @@ portable
Sourceval max_elt : 'a Base.Uniform_array.t -> compare:('a -> 'a -> int) @ local -> 'a option @@ portable
Sourceval sort : ?pos:int -> ?len:int -> 'a Base.Uniform_array.t @ local -> compare:('a -> 'a -> int) @ local -> unit @@ portable

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 Base.Binary_searchable.S1 with type 'a t := 'a Base.Uniform_array.t

See Binary_search.binary_search in binary_search.ml

See Binary_search.binary_search_segmented in binary_search.ml

Sourceval binary_search_segmented : ?pos:int -> ?len:int -> 'a Base.Uniform_array.t -> segment_of:('a -> [ `Left | `Right ]) @ local -> [ `Last_on_left | `First_on_right ] -> int option @ local

Extra lowlevel and unsafe functions

Sourceval unsafe_create_uninitialized : ('a : value_or_null). len:int -> 'a Base.Uniform_array.t @@ portable

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

Sourceval create_obj_array : len:int -> Stdlib.Obj.t Base.Uniform_array.t @@ portable

New obj array filled with Obj.repr 0

Sourceval unsafe_set_assuming_currently_int : Stdlib.Obj.t Base.Uniform_array.t @ local -> int -> Stdlib.Obj.t -> unit @@ portable

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 : Stdlib.Obj.t Base.Uniform_array.t @ local -> int -> int -> unit @@ portable
Sourceval unsafe_set_int : Stdlib.Obj.t Base.Uniform_array.t @ local -> int -> int -> unit @@ portable
Sourceval unsafe_clear_if_pointer : Stdlib.Obj.t Base.Uniform_array.t @ local -> int -> unit @@ portable

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.