package vec

  1. Overview
  2. Docs
Fast, safe mutable dynamic arrays

Install

Dune Dependency

Authors

Maintainers

Sources

v0.2.0.tar.gz
md5=164dfcc886cd450485010821b588b456
sha512=083bdfd37f61245c72c23965d7c0265aee103b2e9646e5fd7ed99579994fb52d356f8b4518560985bbda8729a972b906a7ca7f8516a36a1baa4a4d20204dd410

doc/vec/Vec/index.html

Module VecSource

Mutable dynamic array

Sourcetype ('a, -'p) t

The 'p type parameter is a phantom type parameter that represents the vector's mutability. It is [`R | `W] for read-write vectors, [`R] for read-only vectors, or [`W] for write-only vectors.

Sourceval default_growth_rate : float

The default growth rate of newly-created vectors.

Sourceval make : ?growth_rate:float -> ?capacity:int -> unit -> ('a, [ `R | `W ]) t

Constructs a vector with the specified growth rate and capacity.

Sourceval copy : ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Creates a copy of the specified vector.

Sourceval as_read_only : ('a, [> `R ]) t -> ('a, [ `R ]) t

Reinterprets the specified vector as a read-only vector.

Sourceval as_write_only : ('a, [> `W ]) t -> ('a, [ `W ]) t

Reinterprets the specified vector as a write-only vector.

Sourceval length : ('a, [> ]) t -> int

Returns the length of the specified vector.

Sourceval capacity : ('a, [> ]) t -> int

Returns the capacity of the specified vector.

Sourceval growth_rate : ('a, [> `R ]) t -> float

Returns the growth rate of the specified vector.

Sourceval set_growth_rate : float -> ('a, [ `R | `W ]) t -> unit

Sets the growth rate of the specified vector to the specified value.

Sourceval clear : ('a, [ `R | `W ]) t -> unit

Resets the vector to an empty state.

Sourceval get_exn : ('a, [> `R ]) t -> int -> 'a

Gets the value in the vector at the specified index.

Sourceval set_exn : ('a, [> `W ]) t -> int -> 'a -> unit

Sets the value in the vector at the specified index to the specified value.

Sourceval get : ('a, [> `R ]) t -> int -> 'a option

Gets the value in the vector at the specified index. Returns None if the index is out of range.

Sourceval set : ('a, [> `W ]) t -> int -> 'a -> bool

Sets the value in the vector at the specified index to the specified value. Returns false if the index is out of range.

Sourceval ensure_capacity : int -> ('a, [> `W ]) t -> unit

Increases the vector's capacity to be at least as large as the specified value.

Sourceval reserve : int -> ('a, [> `W ]) t -> unit

Increases the vector's capacity by the specified value.

Sourceval shrink_to_fit : ('a, [ `R | `W ]) t -> unit

Shrinks the vector's internal buffer to only be as large as the vector's length.

Sourceval push : 'a -> ('a, [> `W ]) t -> unit

Pushes the specified item onto the end of the vector.

Sourceval pop : ('a, [ `R | `W ]) t -> 'a option

Pops off the item from the end of the vector.

Sourceval map : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Maps the specified function over the vector, returning a new vector. (Functor map operation)

Sourceval mapi : (int -> 'a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Like map, but the function also takes the item's index as a parameter.

Sourceval map_in_place : ('a -> 'a) -> ('a, [ `R | `W ]) t -> unit

Like map, but the transformation is done in-place.

Sourceval singleton : 'a -> ('a, [ `R | `W ]) t

Returns a singleton vector containing the specified item. (Applicative functor pure operation)

Sourceval map2 : ('a -> 'b -> 'c) -> ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('c, [ `R | `W ]) t

Maps the specified function over all combinations of tuples from the 2 specified vectors, returning a new vector. (Applicative functor liftA2 operation

Sourceval apply : ('a -> 'b, [> `R ]) t -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Applies every function from the first vector to every value from the second vector, returning a new vector. (Applicatve functor ap operation)

Sourceval flatten : (('a, [> `R ]) t, [> `R ]) t -> ('a, [ `R | `W ]) t

Flattens nested vectors into a single, one-dimensional vector. (Monad join operation)

Sourceval flat_map : ('a -> ('b, [> `R ]) t) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Like map, but flattens the result. (Monad bind operation)

Sourceval cartesian_product : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Cartesian product of 2 vectors. (Equivalent to liftA2 (,))

Sourceval iter : ('a -> unit) -> ('a, [> `R ]) t -> unit

Applies the specified function to each item in the vector.

Sourceval iteri : (int -> 'a -> unit) -> ('a, [> `R ]) t -> unit

Like iter, but the function also takes the item's index as a parameter.

Sourceval filter : ('a -> bool) -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Returns a new vector containing only the items from the first vector that satisfy the specified predicate.

Sourceval filteri : (int -> 'a -> bool) -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Like filter, but the predicate also takes the item's index as a parameter.

Sourceval filter_in_place : ('a -> bool) -> ('a, [ `R | `W ]) t -> unit

Performs a filter in-place, based on the specified predicate.

Sourceval of_list : 'a list -> ('a, [ `R | `W ]) t

Constructs a vector from the specified list.

Sourceval to_list : ('a, [> `R ]) t -> 'a list

Constructs a list from the specified vector.

Sourceval of_array : 'a array -> ('a, [ `R | `W ]) t

Constructs a vector from the specified array.

Sourceval to_array : ('a, [> `R ]) t -> 'a array

Constructs an array from the specified vector.

Sourceval rev : ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Returns a new vector that contains all the items in the specified vector, but in reverse order.

Sourceval rev_in_place : ('a, [ `R | `W ]) t -> unit

Reverses the vector in-place.

Sourceval append : ('a, [ `R | `W ]) t -> ('a, [> `R ]) t -> unit

Appends the second vector to the first vector.

Sourceval exists : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if any item in the vector satisfies the specified predicate.

Sourceval for_all : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if all items in the vector satisfies the specified predicate.

Sourceval mem : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses structural equality.

Sourceval memq : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses physical equality.

Sourceval fold_left : ('b -> 'a -> 'b) -> 'b -> ('a, [> `R ]) t -> 'b

Folds the specified function and default value over the array, from left to right.

Sourceval fold_right : ('a -> 'b -> 'b) -> ('a, [> `R ]) t -> 'b -> 'b

Folds the specified function and default value over the array, from right to left.

Sourceval zip : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Zips the two vectors together.

Sourceval zip_with : ('a -> 'b -> 'c) -> ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('c, [ `R | `W ]) t

Zips the two vectors together, using the specified function to combine values.

Sourceval sort : ('a, [ `R | `W ]) t -> unit

Sorts the specified vector.

Sourceval sort_by : ('a -> 'a -> int) -> ('a, [ `R | `W ]) t -> unit

Sorts the specified vector using the specified comparison function.

Sourceval equal : ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality.

Sourceval equal_by : ('a -> 'a -> bool) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality, using the specified equality function for elements.

Sourceval compare : ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically.

Sourceval compare_by : ('a -> 'a -> int) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically, using the specified comparison function for elements.

Sourceval pretty_print : ('a -> string) -> ('a, [> `R ]) t -> string

Returns a string representation of the vector, using the specified function to format each value.

Sourceval iota : int -> int -> (int, [ `R | `W ]) t

Constructs a vector containing all numbers in the specified range.

Sourcemodule Infix : sig ... end

Contains infix versions of some vector operations.

Sourcemodule Let_syntax : sig ... end

Provides support for OCaml 4.08's binding operator syntax.

OCaml

Innovation. Community. Security.