package core_kernel
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=e37370bad978cfb71fdaf2b1a25ab1506b98ef0b91e0dbd189ffd9d853245ce2
doc/core_kernel.vec/Vec/Make/index.html
Module Vec.Make
Source
Generate a specialised version of Vec
with a custom index type.
Parameters
Signature
init n ~f
returns a fresh vector of length n
, with element number i
initialized to the result of f i
. In other words, init n ~f
tabulates the results of f
applied to the integers 0
to n-1
.
Raise Invalid_argument if n < 0
.
sort
uses constant heap space. To sort only part of the array, specify pos
to be the index to start sorting from and len
indicating how many elements to sort.
Grows the vec to the specified length if it is currently shorter. Sets all new indices to default
.
Shortens the vec to the specified length if it is currently longer. Raises if len < 0
.
remove vec i
Removes the i-th element of the vector. This is not a fast implementation, and runs in O(N) time. (ie: it calls caml_modify under the hood)
Find the first element that satisfies f
. If exists, remove the element from the vector and return it. This is not a fast implementation, and runs in O(N) time.
take_while t ~f
returns a fresh vec containing the longest prefix of t
for which f
is true
.
copy t
returns a copy of t
, that is, a fresh vec containing the same elements as t
.
exists t ~f
returns true if f
evaluates true on any element, else false
swap_to_last_and_pop t i
is equivalent to swap t i (length t - 1); pop_back_exn t
. It raises if i
is out of bounds.