package base
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=755e303171ea267e3ba5af7aa8ea27537f3394d97c77d340b10f806d6ef61a14
doc/base/Base/Uniform_array/index.html
Module Base.Uniform_array
Source
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.
See Base.Array
for comments.
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
.
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
.
Same as unsafe_set_with_caml_modify
, but with bounds check.
Like iter
, but the function is applied to the index of the element as first argument, and the element itself as second argument.
of_array
and to_array
return fresh arrays with the same contents rather than returning a reference to the underlying array.
Extra lowlevel and unsafe functions
The behavior is undefined if you access an element before setting it.
New obj array filled with Obj.repr 0
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. Caml.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.
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 Caml.Obj.repr 0
. As a performance hack, it only does this when not (Caml.Obj.is_int t.(i))
. It is an error to access the cleared index before setting it again.
Functions with the 2 suffix raise an exception if the lengths of the two given arrays aren't the same.