package varray
Library
Module
Module type
Parameter
Class
Class type
The array will be used partially, with some elements in an undefined state. It is guaranteed that all operations always use valid indexes.
val length : 'a t -> int
The size of the array; the maximum number of elements that can be stored inside.
val empty : unit -> 'a t
An empty array of length 0
.
val create : int -> 'a t
get t i
returns the i
th element of the array. The elements are numbered from 0
to length t - 1
and the index i
is always within this bound: this function be implemented as an unsafe_get
) if available.
set t i v
modifies t
in place, replacing the element at position i
with the value v
. From now on, the element at this index is defined. Again, this can be implemented as an unsafe_set
without bound checking.
val erase_at : 'a t -> int -> unit
erase_at t i
resets the element at position i
. It is an opportunity to free the memory of the value t.(i)
. From now on, the element is undefined and this index will not be accessed again until a write is done.
blit src i dst j n
copies the elements from the range i,i+n-1
from the array src
to the range j,j+n-1
of the array dst
. All the elements copied from src
are guaranteed to be in a defined state. After this operation, the corresponding range in dst
will be defined. The copied ranges will be valid for each array. Special care is required during the copy since src
will often be the same array as dst
and the ranges can overlap.