Page
Library
Module
Module type
Parameter
Class
Class type
Source
Pvec.Make
SourcePersistent vectors with custom branching factor.
module _ : sig ... end
Persistent vectors with elements of type 'a
.
init n f
returns a vector of length n
holding the elements f(0)
, f(1)
, ... .
append x v
appends x
to the end of vector v
and returns the updated vector.
set i x v
replaces the i-th element of vector v
with x
and returns the updated vector. For i = length v
, set i x v
equals append x v
.
Returns None
if index i
is out of bounds.
get i v
reads the i-th element from vector v
.
Returns None
if index i
is out of bounds.
peek v
returns the last element of vector v
or None
if v
is empty.
pop v
removes the last element of vector v
and returns the removed element together with the updated vector.
Returns None
if v
is empty.
get_exn
is similar to get
but raises Not_found
instead of returning None
.
set_exn
is similar to set
but raises Invalid_argument _
instead of returning None
.
Like List.fold_left
.
Similar to List.fold_right
but does not allocate additional memory.
rev_to_array v
converts vector v
to an array; reverse order.