module Weak:Weak_intf.Twith module Strategy = DefStrat
Resizable weak array using the default reallocation strategy.
module Strategy:Strat.T
Module implementing the reallocation strategy
typestrategy =Strategy.t
Type of reallocation strategy
type 'a t
Type of parameterized resizable arrays
val length : 'a t -> intlength ra
ra excluding the reserved space.val lix : 'a t -> intlix ra
ra excluding the reserved
space.val real_length : 'a t -> intreal_length ra
ra including the reserved space.val real_lix : 'a t -> intreal_lix ra
ra including the reserved space.val get : 'a t -> int -> 'a optionget ra n
Invalid_argument if index out of bounds.nth element of ra.val get_copy : 'a t -> int -> 'a optionget_copy ra n see documentation of module Weak in the standard
distribution.
val check : 'a t -> int -> boolcheck ra n
true if the nth cell of ra is full, false if it is empty. Note
that even if check ar n returns true, a subsequent Weak_intf.T.getar n can
return None.val set : 'a t -> int -> 'a option -> unitset ra n sets the nth element of ra.
Invalid_argument if index out of bounds.val sempty : strategy -> 'a tsempty s
s.val empty : unit -> 'a tempty () same as sempty but uses default strategy.
val screate : strategy -> int -> 'a tscreate s n el
n using strategy s.val create : int -> 'a tcreate n same as screate but uses default strategy.
val sinit : strategy -> int -> (int -> 'a option) -> 'a tsinit s n f
n containing elements that were created by applying
function f to the index, using strategy s.val init : int -> (int -> 'a option) -> 'a tinit n f sames as sinit but uses default strategy.
val get_strategy : 'a t -> strategyget_strategy ra
ra.val set_strategy : 'a t -> strategy -> unitset_strategy ra s sets the reallocation strategy of resizable array ra
to s, possibly causing an immediate reallocation.
val put_strategy : 'a t -> strategy -> unitput_strategy ra s sets the reallocation strategy of resizable array ra
to s. Reallocation is only done at later changes in size.
val enforce_strategy : 'a t -> unitenforce_strategy ra forces a reallocation if necessary (e.g. after a
put_strategy).
val copy : 'a t -> 'a tcopy ra
ra. The two arrays share the same strategy!val sub : 'a t -> int -> int -> 'a tsub ra ofs len
Invalid_argument if parameters do not denote a correct subarray.len from resizable array ra starting
at offset ofs using the default strategy.val fill : 'a t -> int -> int -> 'a option -> unitfill ra ofs len el fills resizable array ra from offset ofs with
len elements el, possibly adding elements at the end. Raises
Invalid_argument if offset ofs is larger than the length of the array.
val blit : 'a t -> int -> 'a t -> int -> int -> unitblit ra1 ofs1 ra2 ofs2 len blits resizable array ra1 onto ra2
reading len elements from offset ofs1 and writing them to ofs2,
possibly adding elements at the end of ra2. Raises Invalid_argument if
ofs1 and len do not designate a valid subarray of ra1 or if ofs2
is larger than the length of ra2.
val append : 'a t -> 'a t -> 'a tappend ra1 ra2
ra1 and
ra2 in this order onto it.val concat : 'a t list -> 'a tconcat l
l in their respective order onto it.val add_one : 'a t -> 'a option -> unitadd_one ra el adds element el to resizable array ra, possibly
causing a reallocation.
val remove_one : 'a t -> unitremove_one ra removes the last element of resizable array ra, possibly
causing a reallocation.
Failure if the array is empty.val remove_n : 'a t -> int -> unitremove_n ra n removes the last n elements of resizable array ra,
possibly causing a reallocation.
Invalid_argument if there are not enough elements or n < 0.val remove_range : 'a t -> int -> int -> unitremove_range ra ofs len removes len elements from resizable array ra
starting at ofs and possibly causing a reallocation.
Invalid_argument if range is invalid.val clear : 'a t -> unitclear ra removes all elements from resizable array ra, possibly
causing a reallocation.
val swap : 'a t -> int -> int -> unitswap ra n m swaps elements at indices n and m.
Invalid_argument if any index is out of range.val swap_in_last : 'a t -> int -> unitswap_in_last ra n swaps the last element with the one at position n.
Invalid_argument if index n is out of range.val to_std : 'a t -> 'a Stdlib.Weak.tto_std ra converts a resizable weak array to a standard one.
val sof_std : strategy -> 'a Stdlib.Weak.t -> 'a tsof_std s ar converts a standard weak array to a resizable one, using
strategy s.
val of_std : 'a Stdlib.Weak.t -> 'a tof_std ar converts a standard weak array to a resizable one using the
default strategy.
val to_list : 'a t -> 'a option listto_list ra converts resizable array ra to a list.
val of_list : 'a option list -> 'a tof_list l creates a resizable array using the default strategy and the
elements in list l.
val iter : ('a option -> unit) -> 'a t -> unititer f ra applies the unit-function f to each element in resizable
array ra.
val iteri : (int -> 'a option -> unit) -> 'a t -> unititeri f ra applies the unit-function f to each index and element in
resizable array ra.
val fold_left : ('b -> 'a option -> 'b) -> 'b -> 'a t -> 'bfold_left f a ra left-folds values in resizable array ra using
function f and start accumulator a.
val fold_right : ('a option -> 'b -> 'b) -> 'a t -> 'b -> 'bfold_right f a ra right-folds values in resizable array ra using
function f and start accumulator a.
val for_all : ('a option -> bool) -> 'a t -> boolfor_all p ra
true if all elements in resizable array ra satisfy the predicate
p, false otherwise.val exists : ('a option -> bool) -> 'a t -> boolexists p ra
true if at least one element in resizable array ra satisfies the
predicate p, false otherwise.val mem : 'a option -> 'a t -> boolmem el ra
true if element el is logically equal to any element in resizable
array ra, false otherwise.val memq : 'a option -> 'a t -> boolmemq el ra
true if element el is physically equal to any element in resizable
array ra, false otherwise.val pos : 'a option -> 'a t -> int optionpos el ra
Some index if el is logically equal to the element at index in
ra, None otherwise. index is the index of the first element that
matches.val posq : 'a option -> 'a t -> int optionposq el ra
Some index if el is physically equal to the element at index in
ra, None otherwise. index is the index of the first element that
matches.val find : ('a option -> bool) -> 'a t -> 'a optionfind p ra
Not_found if there is no such element.ra that satisfies predicate p.val find_index : ('a option -> bool) -> 'a t -> int -> intfind_index p ra pos
Not_found if there is no such element or if pos is larger than the highest
index.Invalid_argument if pos is negative.p in resizable
array ra, starting search at index pos.val filter : ('a option -> bool) -> 'a t -> 'a tfilter p ra
ra that satisfy
predicate p using the same strategy as ra.val find_all : ('a option -> bool) -> 'a t -> 'a tfind_all p ra is the same as filter
val filter_in_place : ('a option -> bool) -> 'a t -> unitfilter_in_place p ra as filter, but filters in place.
val partition : ('a option -> bool) ->
'a t -> 'a t * 'a tpartition p ra
ra that satisfy predicate p, the right one only those that do not
satisfy it. Both returned arrays are created using the strategy of ra.val unsafe_get : 'a t -> int -> 'a option
val unsafe_set : 'a t -> int -> 'a option -> unit
val unsafe_sub : 'a t -> int -> int -> 'a t
val unsafe_fill : 'a t -> int -> int -> 'a option -> unit
val unsafe_blit : 'a t -> int -> 'a t -> int -> int -> unit
val unsafe_remove_one : 'a t -> unit
val unsafe_remove_n : 'a t -> int -> unit
val unsafe_swap : 'a t -> int -> int -> unit
val unsafe_swap_in_last : 'a t -> int -> unit