package carray

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

Module CarraySource

Sourcetype 'a t

The type of C arrays

Sourceval make : int -> 'a -> 'a t

make n x returns a fresh array of length n, initialized with x. Each element of the array is a fresh copy of a. This is different from Array.make

Sourceval init : int -> (int -> 'a) -> 'a t

init n f returns a fresh array of length n, with element number i initialized to the result of f i. In other terms, init n f tabulates the results of f applied to the integers 0 to n-1.

Sourceval of_array : 'a array -> 'a t

of_array a builds a C array with the same content than the Caml array a

Sourceval to_array : 'a t -> 'a array

to_array a returns a Caml array with the same content than the C array a

Sourceval of_list : 'a list -> 'a t

of_list l returns a C array with the same content than the list l

Sourceval to_list : 'a t -> 'a list

to_list a returns a Caml list with the same content than the array a

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

set a n x modifies array a in place, replacing element number n with x

Sourceval get : 'a t -> int -> 'a

get a n gets an returns the element number n of the array a. The first element has number 0. The last element has number length length - 1.

Sourceval length : 'a t -> int

Return the length (number of elements) of the given array

Sourceval sub : 'a t -> int -> int -> 'a t

sub a pos len returns a fresh array of length len, containing the elements number pos to pos + len - 1 of array a.

Sourceval sub_noalloc : 'a t -> int -> int -> 'a t

sub_noalloc a pos len is the same than sub but does not perform allocation. The elements of the output are physically the same than the input. Consequently, modifying the elements of the input will modify the output, and inversely.

Sourceval copy : 'a t -> 'a t

copy a returns a fresh copy of a

Sourceval iter : ('a -> unit) -> 'a t -> unit

iter f a iterates f over a

Sourceval iteri : (int -> 'a -> unit) -> 'a t -> unit

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

Sourceval for_all : ('a -> bool) -> 'a t -> bool

for_all f a checks if all elements of the array satisfy the predicate f

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f a applies function f to all the elements of a, and builds an array with the results returned by f: [| f a.(0); f a.(1); ...; f a.(length a - 1) |].

Sourceval append : 'a t -> 'a t -> 'a t

append v1 v2 returns a fresh array containing the concatenation of the arrays v1 and v2.

Raises Invalid_argument if length v1 + length v2 > Sys.max_array_length

Sourceval concat : 'a t list -> 'a t

Same as append, but concatenates a list of arrays

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

fill a pos len x modifies the array a in place, storing x in elements number pos to pos + len - 1.

Raises Invalid_argument if pos and len do not designate a valid subarray of a.

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

blit src src_pos dst dst_pos len copies len elements from array src, starting at element number src_pos, to array dst, starting at element number dst_pos. It works correctly even if src and dst are the same array, and the source and destination chunks overlap.

Raises Invalid_argument if src_pos and len do not designate a valid subarray of src, or if dst_pos and len do not designate a valid subarray of dst.

Sourceval exists : ('a -> bool) -> 'a t -> bool

exists f [|a1; ...; an|] checks if at least one element of the array satisfies the predicate f. That is, it returns (f a1) || (f a2) || ... || (f an).

Sourceval mem : 'a -> 'a t -> bool

mem a set is true if and only if a is structurally equal to an element of l (i.e. there is an x in l such that compare a x = 0).

OCaml

Innovation. Community. Security.