Containers_pvec
Functional Vectors.
These are trees with a large branching factor for logarithmic operations with a low multiplicative factor.
status: experimental
val empty : 'a t
Empty vector.
val is_empty : _ t -> bool
Is the vector empty?
val return : 'a -> 'a t
Single element vector.
val length : _ t -> int
Number of elements. Constant time.
val make : int -> 'a -> 'a t
make n x
makes a vector with n
copies of the element x
val get : 'a t -> int -> 'a
val get_opt : 'a t -> int -> 'a option
val last : 'a t -> 'a
Last element.
val last_opt : 'a t -> 'a option
Like pop_opt
but doesn't return the last element. Returns the same vector if it's empty.
val iter : ('a -> unit) -> 'a t -> unit
val iter_rev : ('a -> unit) -> 'a t -> unit
Iterate on elements but starting from the end.
val iteri : (int -> 'a -> unit) -> 'a t -> unit
Iterate on elements with their index, in increasing order.
val iteri_rev : (int -> 'a -> unit) -> 'a t -> unit
Iterate on elements with their index, but starting from the end.
val fold_left : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val fold_rev : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val fold_lefti : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b
val fold_revi : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b
append a b
adds all elements of b
at the end of a
. This is at least linear in the length of b
.
val choose : 'a t -> 'a option
Return an element. It is unspecified which one is returned.
val to_list : 'a t -> 'a list
val of_list : 'a list -> 'a t
val of_seq : 'a Stdlib.Seq.t -> 'a t
val to_seq : 'a t -> 'a Stdlib.Seq.t