package containers

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Containers_pvecSource

Functional Vectors.

These are trees with a large branching factor for logarithmic operations with a low multiplicative factor.

status: experimental

  • since 3.13.1
Sourcetype 'a iter = ('a -> unit) -> unit
Sourcetype !'a t
Sourceval empty : 'a t

Empty vector.

Sourceval is_empty : _ t -> bool

Is the vector empty?

Sourceval return : 'a -> 'a t

Single element vector.

Sourceval length : _ t -> int

Number of elements. Constant time.

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

make n x makes a vector with n copies of the element x

Sourceval push : 'a t -> 'a -> 'a t

Add element at the end.

Sourceval get : 'a t -> int -> 'a
Sourceval get_opt : 'a t -> int -> 'a option
Sourceval last : 'a t -> 'a

Last element.

Sourceval last_opt : 'a t -> 'a option
Sourceval pop : 'a t -> 'a * 'a t

Pop last element.

Sourceval pop_opt : 'a t -> ('a * 'a t) option

Pop last element.

Sourceval drop_last : 'a t -> 'a t

Like pop_opt but doesn't return the last element. Returns the same vector if it's empty.

Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
Sourceval iter : ('a -> unit) -> 'a t -> unit
Sourceval iter_rev : ('a -> unit) -> 'a t -> unit

Iterate on elements but starting from the end.

Sourceval iteri : (int -> 'a -> unit) -> 'a t -> unit

Iterate on elements with their index, in increasing order.

Sourceval iteri_rev : (int -> 'a -> unit) -> 'a t -> unit

Iterate on elements with their index, but starting from the end.

Sourceval fold_left : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
Sourceval fold_rev : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
Sourceval fold_lefti : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b
Sourceval fold_revi : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b
Sourceval append : 'a t -> 'a t -> 'a t

append a b adds all elements of b at the end of a. This is at least linear in the length of b.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t
Sourceval choose : 'a t -> 'a option

Return an element. It is unspecified which one is returned.

Sourceval to_list : 'a t -> 'a list
Sourceval of_list : 'a list -> 'a t
Sourceval add_list : 'a t -> 'a list -> 'a t
Sourceval add_iter : 'a t -> 'a iter -> 'a t
Sourceval of_iter : 'a iter -> 'a t
Sourceval to_iter : 'a t -> 'a iter
Sourceval add_seq : 'a t -> 'a Seq.t -> 'a t
Sourceval of_seq : 'a Seq.t -> 'a t
Sourceval to_seq : 'a t -> 'a Seq.t
OCaml

Innovation. Community. Security.