package containers-data

  1. Overview
  2. Docs
A set of advanced datatypes for containers

Install

Dune Dependency

Authors

Maintainers

Sources

containers-3.15.tbz
sha256=92143ceb4785ae5f8a07f3ab4ab9f6f32d31ead0536e9be4fdb818dd3c677e58
sha512=5fa80189d0e177af2302b48e72b70299d51fc36ac2019e1cbf389ff6a7f4705b10089405b5a719b3e4845b0d1349a47a967f865dc2e4e3f0d5a0167ef6c31431

doc/containers-data/CCImmutArray/index.html

Module CCImmutArraySource

Immutable Arrays

Purely functional use of arrays. Update is costly, but reads are very fast. Sadly, it is not possible to make this type covariant without using black magic.

  • since 0.17
Sourcetype 'a t

Array of values of type 'a. The underlying type really is an array, but it will never be modified.

It should be covariant but OCaml will not accept it.

Sourceval empty : 'a t
Sourceval length : _ t -> int
Sourceval singleton : 'a -> 'a t
Sourceval doubleton : 'a -> 'a -> 'a t
Sourceval make : int -> 'a -> 'a t

make n x makes an array of n times x.

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

init n f makes the array [| f 0; f 1; ... ; f (n-1) |].

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

Access the element.

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

Copy the array and modify its copy.

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

sub a start len returns a fresh array of length len, containing the elements from start to pstart + len - 1 of array a.

Raises Invalid_argument "Array.sub" if start and len do not designate a valid subarray of a; that is, if start < 0, or len < 0, or start + len > Array.length a.

  • since 1.5
Sourceval map : ('a -> 'b) -> 'a t -> 'b t
Sourceval mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
Sourceval append : 'a t -> 'a t -> 'a t
Sourceval iter : ('a -> unit) -> 'a t -> unit
Sourceval iteri : (int -> 'a -> unit) -> 'a t -> unit
Sourceval foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a
Sourceval fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
Sourceval for_all : ('a -> bool) -> 'a t -> bool
Sourceval exists : ('a -> bool) -> 'a t -> bool

Conversions

Sourcetype 'a iter = ('a -> unit) -> unit
Sourcetype 'a gen = unit -> 'a option
Sourceval of_list : 'a list -> 'a t
Sourceval to_list : 'a t -> 'a list
Sourceval of_array_unsafe : 'a array -> 'a t

Take ownership of the given array. Careful, the array must NOT be modified afterwards!

Sourceval to_iter : 'a t -> 'a iter
Sourceval of_iter : 'a iter -> 'a t
Sourceval of_gen : 'a gen -> 'a t
Sourceval to_gen : 'a t -> 'a gen

IO

Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourceval pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf a formats the array a on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

OCaml

Innovation. Community. Security.

On This Page
  1. Conversions
  2. IO