package alt-ergo-lib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t = {
  1. mutable data : 'a array;
  2. mutable sz : int;
  3. dummy : 'a;
}

Type of vectors of 'a elements.

val make : int -> dummy:'a -> 'a t

make cap dummy creates a new vector filled with dummy. The vector is initially empty but its underlying array has capacity cap. dummy will stay alive as long as the vector

val create : dummy:'a -> 'a t

create ~dummy creates an empty vector using dummy as dummy values.

val to_list : 'a t -> 'a list

Returns the list of elements of the vector.

val to_rev_list : 'a t -> 'a list

Returns the list of elements of the vector in reversed order.

val to_array : 'a t -> 'a array
val of_list : 'a list -> dummy:'a -> 'a t
val clear : 'a t -> unit

clear vec sets the size of vec to zero and free the elements.

val shrink : 'a t -> int -> unit

shrink vec sz resets size of vec to sz and frees its elements. Assumes sz >=0 && sz <= size vec.

val pop : 'a t -> 'a

Pop last element, free and return it.

val last : 'a t -> 'a

Return the last element.

val grow_to_by_double : 'a t -> int -> unit

grow_to_by_double vec c grow the capacity of the vector by double it.

val size : 'a t -> int

Returns the size of the vector.

val is_empty : 'a t -> bool

Returns true if and only if the vector is of size 0.

val is_full : 'a t -> bool

Is the capacity of the vector equal to the number of its elements?

val push : 'a t -> 'a -> unit

Push element into the vector.

val get : 'a t -> int -> 'a

Get the element at the given index, or

val set : 'a t -> int -> 'a -> unit

Set the element at the given index, either already set or the first free slot if not (is_full vec), or

val replace : ('a -> 'a) -> 'a t -> int -> unit

replace f vec n is equalivalent to set vec n (f (get vec n)), but with a single bound check.

val copy : 'a t -> 'a t

Fresh copy.

val fast_remove : 'a t -> int -> unit

Remove element at index i without preserving order (swap with last element).

val filter_in_place : ('a -> bool) -> 'a t -> unit

filter_in_place p vec removes from vec the elements that do not satisfy p.

val sort : 'a t -> ('a -> 'a -> int) -> unit

Sort in place the vector.

val iter : ('a -> unit) -> 'a t -> unit

Iterate on elements.

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

Iterate on elements with their index.

val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b

Fold over elements.

val exists : ('a -> bool) -> 'a t -> bool

Does there exist an element that satisfies the predicate?

val for_all : ('a -> bool) -> 'a t -> bool

Do all elements satisfy the predicate?

val pp : 'a Fmt.t -> 'a t Fmt.t

pp pp_elt ppf vec prints on the formatter ppf all the elements of vec using the printer pp_elt. Dummy values are also printed.

OCaml

Innovation. Community. Security.