A growable array of 'a. Designed for efficiency and simplicity.
This interface is generated lazily: if you need a standard function we haven't added, feel free to add or ping the authors.
By default, Vec operations use integers as indices. The functor Make can be used to create a specialized version from any module implementing Intable.S.
include Ppx_compare_lib.Comparable.S1 with type 'a t := 'a t
Sourceval compare :
'a Base__Ppx_compare_lib.compare ->
'a t Base__Ppx_compare_lib.compare include Ppx_compare_lib.Equal.S1 with type 'a t := 'a t
Sourceval equal : 'a Base__Ppx_compare_lib.equal -> 'a t Base__Ppx_compare_lib.equal include Core.Invariant.S1 with type 'a t := 'a t
Sourceval invariant : 'a Base__Invariant_intf.inv -> 'a t Base__Invariant_intf.inv Sourceval create : ?initial_capacity:int -> unit -> 'a t Sourceval init : int -> f:(int -> 'a) -> 'a t init n ~f returns a fresh vector of length n, with element number i initialized to the result of f i. In other words, init n ~f tabulates the results of f applied to the integers 0 to n-1.
Raise Invalid_argument if n < 0.
Raises if the index is invalid.
Sourceval maybe_get : 'a t -> int -> 'a option Sourceval set : 'a t -> int -> 'a -> unit Raises if the index is invalid.
include Core.Container.S1 with type 'a t := 'a t
Sourceval mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool Sourceval iter : 'a t -> f:('a -> unit) -> unit Sourceval fold : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc Sourceval fold_result :
'a t ->
init:'acc ->
f:('acc -> 'a -> ('acc, 'e) Base__.Result.t) ->
('acc, 'e) Base__.Result.t Sourceval fold_until :
'a t ->
init:'acc ->
f:('acc -> 'a -> ('acc, 'final) Base__Container_intf.Continue_or_stop.t) ->
finish:('acc -> 'final) ->
'final Sourceval for_all : 'a t -> f:('a -> bool) -> bool Sourceval count : 'a t -> f:('a -> bool) -> int Sourceval sum :
(module Base__Container_intf.Summable with type t = 'sum) ->
'a t ->
f:('a -> 'sum) ->
'sum Sourceval find : 'a t -> f:('a -> bool) -> 'a option Sourceval find_map : 'a t -> f:('a -> 'b option) -> 'b option Sourceval to_array : 'a t -> 'a array Sourceval min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option Sourceval max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option include Core.Blit.S1 with type 'a t := 'a t
val blit : ('a t, 'a t) Base__Blit_intf.blitval blito : ('a t, 'a t) Base__Blit_intf.blitoval unsafe_blit : ('a t, 'a t) Base__Blit_intf.blitval sub : ('a t, 'a t) Base__Blit_intf.subval subo : ('a t, 'a t) Base__Blit_intf.suboSourceval find_exn : 'a t -> f:('a -> bool) -> 'a Finds the first 'a for which f is true *
Sourceval sort : ?pos:int -> ?len:int -> 'a t -> compare:('a -> 'a -> int) -> unit sort uses constant heap space. To sort only part of the array, specify pos to be the index to start sorting from and len indicating how many elements to sort.
Sourceval is_sorted : 'a t -> compare:('a -> 'a -> int) -> bool Sourceval next_free_index : 'a t -> int Sourceval push_back : 'a t -> 'a -> unit Sourceval push_back_index : 'a t -> 'a -> int Sourceval grow_to : 'a t -> len:int -> default:'a -> unit Grows the vec to the specified length if it is currently shorter. Sets all new indices to default.
Sourceval shrink_to : 'a t -> len:int -> unit Shortens the vec to the specified length if it is currently longer. Raises if len < 0.
Sourceval remove_exn : 'a t -> int -> unit remove vec i Removes the i-th element of the vector. This is not a fast implementation, and runs in O(N) time. (ie: it calls caml_modify under the hood)
Sourceval find_and_remove : 'a t -> f:('a -> bool) -> 'a option Find the first element that satisfies f. If exists, remove the element from the vector and return it. This is not a fast implementation, and runs in O(N) time.
Sourceval pop_back_exn : 'a t -> 'a Sourceval pop_back_unit_exn : 'a t -> unit Sourceval peek_back : 'a t -> 'a option Sourceval peek_back_exn : 'a t -> 'a Sourceval iteri : 'a t -> f:(int -> 'a -> unit) -> unit Sourceval to_list : 'a t -> 'a list Sourceval to_alist : 'a t -> (int * 'a) list Sourceval of_list : 'a list -> 'a t Sourceval of_array : 'a array -> 'a t Sourceval take_while : 'a t -> f:('a -> bool) -> 'a t take_while t ~f returns a fresh vec containing the longest prefix of t for which f is true.
The number of elements we can hold without growing.
clear t discards all elements from t in O(length) time.
copy t returns a copy of t, that is, a fresh vec containing the same elements as t.
Sourceval exists : 'a t -> f:('a -> bool) -> bool exists t ~f returns true if f evaluates true on any element, else false
Sourceval swap : _ t -> int -> int -> unit swap the values at the provided indices
Sourceval swap_to_last_and_pop : 'a t -> int -> 'a swap_to_last_and_pop t i is equivalent to swap t i (length t - 1); pop_back_exn t. It raises if i is out of bounds.
Sourceval unsafe_get : 'a t -> int -> 'a Sourceval unsafe_set : 'a t -> int -> 'a -> unit Generate a specialised version of Vec with a custom index type.