You can search for identifiers within the package.
in-package search v0.2.0
Source file varray_sig.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379moduletypeARRAY=sig(** The array will be used partially, with some elements in an undefined
state. It is guaranteed that all operations always use valid indexes.
*)type'at(** The type of an array. *)type'aelt(** The type of elements contained in the array. *)vallength:'at->int(** The size of the array; the maximum number of elements that can be stored
inside. *)valempty:unit->'at(** An empty array of length [0]. *)valcreate:int->'at(** [create n] returns an array of length [n]. Its elements are all in
an undefined state and will not be accessed by {! get} before being
defined by {! set} or {! blit}. *)valget:'at->int->'aelt(** [get t i] returns the [i]th element of the array.
The elements are numbered from [0] to [length t - 1] and the index [i] is
always within this bound: this function can be implemented as an
[unsafe_get]) if available. *)valset:'at->int->'aelt->unit(** [set t i v] modifies [t] in place, replacing the element at position [i]
with the value [v]. From now on, the element at this index is defined.
Again, this can be implemented as an [unsafe_set] without bound checking.
*)valerase_at:'at->int->unit(** [erase_at t i] resets the element at position [i]. It is an opportunity
to free the memory of the value [t.(i)]. From now on, the element is
undefined and this index will not be accessed again until a write is
done. *)valblit:'at->int->'at->int->int->unit(** [blit src i dst j n] copies the elements from the range [i,i+n-1] from
the array [src] to the range [j,j+n-1] of the array [dst]. All the
elements copied from [src] are guaranteed to be in a defined state.
After this operation, the corresponding range in [dst] will be defined.
The copied ranges will be valid for each array. Special care is required
during the copy since [src] will often be the same array as [dst] and the
ranges can overlap. *)endmoduletypeTIER=sigmoduleArray:ARRAYtype'aelt='aArray.elttype'aarray='aArray.ttype'atvaldepth:intvalempty:unit->'atvalis_empty:'at->boolvalroot_capacity:'at->intvalcreate:capacity:int->'atvalmake:lc:int->int->'aelt->'atvalinit:lc:int->offset:int->int->(int->'aelt)->'atvallength:'at->intvalcapacity:lc:int->intvalget:lc:int->'at->int->'aeltvalset:lc:int->'at->int->'aelt->unitvalpop_front:lc:int->'at->'aeltvalpop_back:lc:int->'at->'aeltvalpop_at:lc:int->'at->int->'aeltvalpush_front:lc:int->'at->'aelt->unitvalpush_back:lc:int->'at->'aelt->unitvalis_full:lc:int->'at->boolvalpush_front_pop_back:lc:int->'at->'aelt->'aeltvalpush_back_pop_front:lc:int->'at->'aelt->'aeltvalinsert_at:lc:int->'at->int->'aelt->unitendmoduletypeVARRAY=sigtype'attype'aelttype'aarrayvalpush_back:'at->'aelt->unitvalpop_back:'at->'aeltvalpush_front:'at->'aelt->unitvalpop_front:'at->'aeltvalinsert_at:'at->int->'aelt->unitvalpop_at:'at->int->'aeltvaldelete_at:'at->int->unitvalget:'at->int->'aeltvalset:'at->int->'aelt->unitvallength:'at->intvalmake:int->'aelt->'atvalinit:int->(int->'aelt)->'atvalempty:unit->'atvalis_empty:'at->boolvalprotect:'at->(unit->'b)->'bmoduleTier:TIERwithtype'aArray.elt='aeltandtype'aArray.t='aarrayendmoduletypeS=sigtype'at(** The type of a varray. *)type'aelt(** The type of elements stored in the varray. *)(** {1 Dynamic collection} *)valpush_back:'at->'aelt->unit(** [push_back t x] adds a new element [x] at the end of the varray [t].
{b O(k)} amortized. *)valpop_back:'at->'aelt(** [pop_back t] removes and returns the rightmost element of the varray [t].
{b O(k)} amortized. *)valpush_front:'at->'aelt->unit(** [push_front t x] inserts a new element [x] at position [0], on the left
side of the varray [t]. Every previous element of [t] is shifted one to
the right. {b O(k)} amortized. *)valpop_front:'at->'aelt(** [pop_front t] removes and returns the leftmost element at position [0] of
the varray [t]. Every element of [t] is shifted one to the right.
{b O(k)} amortized. *)valinsert_at:'at->int->'aelt->unit(** [insert_at t i x] inserts the element [x] at position [i] in the varray
[t]. Every element on the right of [i] is shifted by one.
{b O(k² × {%html:<sup>k</sup>%}√N)}
- [insert_at t 0 x] is the same as [push_front t x]
- [insert_at t (length t) x] is the same as [push_back t x]
@raise Invalid_argument if [i] is negative or larger than [length t].
*)valpop_at:'at->int->'aelt(** [pop_at t i] removes and returns the element [t.(i)]. Every element on
the right of [i] is shifted by one to the left.
{b O(k² × {%html:<sup>k</sup>%}√N)}
- [pop_at t 0] is the same as [pop_front t]
- [pop_at t (length t - 1)] is the same as [pop_back t]
@raise Invalid_argument if [i] is negative or larger than [length t - 1].
*)valdelete_at:'at->int->unit(** [delete_at t i] removes the element [t.(i)]. Every element on the right
of [i] is shifted by one to the left.
{b O(k² × {%html:<sup>k</sup>%}√N)}
@raise Invalid_argument if [i] is negative or larger than [length t - 1].
*)(** {1 Freeze during traversals} *)(** The previous operations all fail when the varray is being traversed: *)valprotect:'at->(unit->'b)->'b(** [protect t fn] marks [t] as protected during the execution of [fn ()].
All operations that would update the length of [t] by pushing or poping
elements will raise a [Failure] indicating that the traversal is unsafe.
*)(** {1 Array} *)valget:'at->int->'aelt(** [get t i] returns the [i]th element of the varray. Indexing starts from
[0] upto [length t - 1]. {b O(k)}
@raise Invalid_argument if [i] is negative
or larger than [length t - 1].
*)valset:'at->int->'aelt->unit(** [set t i v] updates the value of the [i]th element to [x]. {b O(k)}
@raise Invalid_argument if [i] is negative
or larger than [length t - 1].
*)vallength:'at->int(** [length t] returns the number of elements stored in [t]. {b O(1)} *)valmake:int->'aelt->'at(** [make n x] returns a new varray of length [n], where all the elements are
initialized to the value [x].
@raise Invalid_argument if [n] is negative.
*)valinit:int->(int->'aelt)->'at(** [init n f] returns a new array of length [n], where the element at
position [i] is initialized to [f i].
@raise Invalid_argument if [n] is negative.
*)valempty:unit->'at(** [empty ()] is a new varray of length [0]. *)valis_empty:'at->bool(** [is_empty t] returns true when the varray [t] has length [0]. *)(** {1 Copying elements} *)valappend:'at->'at->'at(** [append a b] returns a new varray by concatening the elements of [a] with
those of [b]. *)valconcat:'atlist->'at(** [concat ts] returns a new varray whose elements are in the same order as
the values from the list of varrays [ts]. *)valsub:'at->int->int->'at(** [sub t i n] returns a new varray of length [n], containing the elements
from the range [i, i+n-1] of the varray [t].
@raise Invalid_argument if the range [i, i + n - 1] is invalid for [t].
*)valcopy:'at->'at(** [copy t] returns a new varray containing the same sequence of
elements as [t]. *)valfill:'at->int->int->'aelt->unit(** [fill t pos len x] modifies the varray [t] in place, by setting the value
[x] in the range [pos, pos + len - 1].
@raise Invalid_argument if the range [pos, pos + len -1] is invalid.
*)valblit:'at->int->'at->int->int->unit(** [blit src src_pos dst dst_pos len] updates the varray [dst] in place, by
copying the range [src_pos, src_pos + len - 1] of values from [src] into
the destination range [dst_pos, dst_pos + len - 1] of [dst].
@raise Invalid_argument if the ranges are invalid for either varray.
*)(** {1 Traversals} *)valiter:('aelt->unit)->'at->unit(** [iter f t] calls the function [f] on all elements of [t], from left to
right. *)valiteri:(int->'aelt->unit)->'at->unit(** [iteri f t] calls [f i t.(i)] on all the indexes [i] of [t],
from left to right. *)valmap:('aelt->'belt)->'at->'bt(** [map f t] returns a new varray, whose elements are [f x] for each [x]
from the varray [t]. *)valmapi:(int->'aelt->'belt)->'at->'bt(** [mapi f t] returns a new varray, whose elements are [f i t.(i)] for each
index [i] of the varray [t]. *)valfold_left:('a->'belt->'a)->'a->'bt->'a(** [fold_left f z t] computes
[f (... (f (f z t.(0)) t.(1)) ...) t.(length t - 1)]. *)valfold_right:('aelt->'b->'b)->'at->'b->'b(** [fold_right f t z] computes
[f t.(0) (f t.(1) (... (f z t.(length t - 1))))]. *)valfold_left_map:('a->'belt->'a*'celt)->'a->'bt->'a*'ct(** [fold_left_map] is a combination of [fold_left] and [map],
that threads an accumulator. *)(** {1 Iterators on two varrays} *)valiter2:('aelt->'belt->unit)->'at->'bt->unit(** [iter2 f xs ys] calls [f xs.(i) ys.(i)] for each index [i] from left to
right.
@raise Invalid_argument if the two varrays have different lengths.
*)valmap2:('aelt->'belt->'celt)->'at->'bt->'ct(** [map2 f xs ys] returns a new varray whose [i]th element is
[f xs.(i) ys.(i)].
@raise Invalid_argument if the two varrays have different lengths.
*)(** {1 Predicates} *)valfor_all:('aelt->bool)->'at->bool(** [for_all f t] holds when [f] is satisfied by all the elements of [t]. *)valfor_all2:('aelt->'belt->bool)->'at->'bt->bool(** [for_all2 f xs ys] holds when [f xs.(i) ys.(i)] is satisfied by all
indexes [i].
@raise Invalid_argument if the two varrays have different lengths.
*)valexists:('aelt->bool)->'at->bool(** [exists f t] holds when [f] is satisfied by one of the elements of
[t]. *)valexists2:('aelt->'belt->bool)->'at->'bt->bool(** [exists2 f xs ys] holds when an index [i] exists such that
[f xs.(i) ys.(i)] is satisfied.
@raise Invalid_argument if the two varrays have different lengths.
*)valfind_opt:('aelt->bool)->'at->'aeltoption(** [find_opt f t] returns the leftmost element of [t] that satisfies [f]. *)valfind_map:('aelt->'boption)->'at->'boption(** [find_map f t] returns the first result of [f] of the form [Some v]. *)valmem:'aelt->'at->bool(** [mem x t] is true when [x] is equal [( = )] to an element of the varray
[t]. *)valmemq:'aelt->'at->bool(** Same as [mem], but [memq x t] uses physical equality [( == )] for
comparison. *)(** {1 Sort} *)valsort:('aelt->'aelt->int)->'at->unit(** [sort cmp t] updates [t] inplace by sorting the elements in increasing
order according to [cmp]. *)valstable_sort:('aelt->'aelt->int)->'at->unit(** Same as [sort], but equal elements are kept in the same relative
order. *)valfast_sort:('aelt->'aelt->int)->'at->unit(** Same as [sort]. *)(** {1 Conversions} *)type'aarray(** The array type used behind the scene as a backend by the varray. *)valof_array:'aarray->'at(** [of_array arr] returns a new varray containing all the elements of the
array [arr]. *)valto_array:'at->'aarray(** [to_array t] returns a new array containing all the elements of the
varray [t]. *)valof_list:'aeltlist->'at(** [of_list xs] returns a new varray containing all the elements of the list
[xs]. *)valto_list:'at->'aeltlist(** [to_list t] returns a list of all the elements of [t]. *)end