module Vector:sig
..end
Efficient persistent vectors based on RRB-Trees
RRB (Relaxed Radix-Balanced) Trees allows "effectively constant" operations like getting element / updating at index, appending and splitting.
type '_
t
module Builder:sig
..end
Efficient construction of vectors using mutable, one-by-one appending of elements
exception Out_of_bounds of {
|
index : |
|
size : |
val empty : 'a t
Empty vector.
val cons : 'a -> 'a t -> 'a t
Prepend one element to vector. "Effectively constant".
val snoc : 'a t -> 'a -> 'a t
Apppend one element to vector. "Effectively constant".
val length : 'a t -> int
The length of a vector.
val init : int -> (int -> 'a) -> 'a t
init l f
creates vector of length l
where value at position i
is
initialized with f i
.
val append : 'a t -> 'a t -> 'a t
Concatenates two vectors. "Effectively constant".
val get : 'a t -> int -> 'a
get v i
returns the element of a v
at position i
. "Effectively
constant".
Raise Out_of_bounds
when i
is outside of v
bounds.
val update : 'a t -> int -> 'a -> 'a t
update v i x
returns new vector initialized with values of v
where
value at index i
is replaced with x
. "Effectively constant".
Raise Out_of_bounds
when i
is outside of v
bounds.
val split_at : 'a t -> int -> 'a t * 'a t
split_at v i
returns pair of a vectors where first element is the prefix
of v
of length i
and second is the suffix of v
starting at i
.
"Effectively constant".
Raise Out_of_bounds
when i
is negative.
val take : 'a t -> int -> 'a t
take v i
returns the prefix of v
of length i
. "Effectively
constant".
Raise Out_of_bounds
when i
is negative.
val drop : 'a t -> int -> 'a t
drop v i
returns the suffix of v
starting at i
. "Effectively
constant".
Raise Out_of_bounds
when i
is negative.
val iter : ('a -> unit) -> 'a t -> unit
iter f v
iterates over v
applying f
to each element.
val of_list : 'a list -> 'a t
Converts list to vector
val to_list : 'a t -> 'a list
Converts vector to list
include Monad.S
include Foldable.S
include Align.S
module A:
module A2:functor (
A
:
Applicative.Basic2
) ->
Traversable.S2
with type 'a t := 'a t and type ('u, 'a) f := ('u, 'a) A.t
module A3:functor (
A
:
Applicative.Basic3
) ->
Traversable.S3
with type 'a t := 'a t and type ('u, 'v, 'a) f := ('u, 'v, 'a) A.t
module M:
module M2:
module M3: