package hector

  1. Overview
  2. Docs
type element

The type of elements.

type dummy = element

The function alloc expects a dummy element.

type t = element array

The type of arrays.

type length = int

The length of an array is a nonnegative integer.

type index = int

An index into an array is an integer value in the semi-open interval [0,n), where n is the length of the array.

type offset = int

An offset into an array is an integer value in the closed interval [0,n], where n is the length of the array. When an offset o and a length k are used in concert to designate an array segment, both o and o+k must be valid offsets.

val empty : t

The empty array.

val length : t -> length

length a returns the length of the array a.

val unsafe_get : t -> index -> element

unsafe_get a i returns the element found at index i in the array a. The index i must be valid, or all hell may break loose.

val unsafe_set : t -> index -> element -> unit

unsafe_set a i x writes the value x at index i in the array a. The index i must be valid, or all hell may break loose.

val alloc : length -> dummy -> t

alloc n d returns a new array of length n. The dummy element d may be used to initialize this array, but this is not guaranteed. Thus, this array must be considered uninitialized: every slot must be written before it is read.

val make : length -> element -> t

make n x returns a new array of length n, where every slot contains the value x.

val grow : length -> element -> t -> length -> t

grow n d a k returns a new array of length n. The lower segment of this array, determined by offset 0 and length k, is initialized by copying data from array a, at offset 0 and length k. The inequality k <= n must hold. The upper segment of this array, determined by offset k and length n - k, must be considered uninitialized: every slot must be written before it is read.

val init : length -> (index -> element) -> t

init n f returns a new array of length n, where the slot at index i contains the value f i.

val sub : t -> offset -> length -> t

sub a o k returns a new array of length k whose content is the content of the array segment identified by array a, offset o, and length k.

val unsafe_blit : t -> offset -> t -> offset -> length -> unit

unsafe_blit a1 o1 a2 o2 k copies the content of the array segment identified by array a1, offset o1, and length k into the array segment identified by array a2, offset o2, and length k. No bounds check is performed.

val blit : t -> offset -> t -> offset -> length -> unit

blit a1 o1 a2 o2 k copies the content of the array segment identified by array a1, offset o1, and length k into the array segment identified by array a2, offset o2, and length k.

val fill : t -> int -> int -> element -> unit

fill a o k x fills the array segment identified by array a, offset o, and length k with the value x.

OCaml

Innovation. Community. Security.