equal eq as1 as2 is true if the lengths of as1 and as2 are the same
and if the corresponding elements test equal using eq.
compare cmp as1 as2 compares the two slices as1 and as2 using
the comparison function cmp, element by element.
val get : 'a t ‑> int ‑> 'aget as n returns the element number n of slice as.
The first element has number 0.
The last element has number length as - 1.
You can also write as.(n) instead of get as n.
Raise Invalid_argument "index out of bounds"
if n is outside the range 0 to (length as - 1).
val get_safe : 'a t ‑> int ‑> 'a optionget_safe as i returns Some as.(i) if i is a valid index.
val make : 'a array ‑> int ‑> len:int ‑> 'a tmake a i ~len creates a slice from given offset i and length len of the given array a.
val of_slice : ('a array * int * int) ‑> 'a tof_slice (a, i, len) makes a slice from a triple (a, i, len) where a is the array,
i the offset in a, and len the number of elements of the slice.
val to_slice : 'a t ‑> 'a array * int * intto_slice as converts the slice as into a triple (a, i, len) where len is the length of
the sub-array of a starting at offset i.
val underlying : 'a t ‑> 'a arrayunderlying as returns the underlying array (shared). Modifying this array will modify
the slice as.
sub as i len builds a new sub-slice that contains the given subrange specified
by the index i and the length len.
val set : 'a t ‑> int ‑> 'a ‑> unitset as n x modifies the slice as in place, replacing
element number n with x.
You can also write as.(n) <- x instead of set as n x.
Raise Invalid_argument "index out of bounds"
if n is outside the range 0 to length as - 1.
val fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afold f acc as computes f (... (f (f acc as.(0)) as.(1)) ...) as.(length as - 1).
val foldi : ('a ‑> int ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afoldi f acc as is just like fold but it also passes in the index of each element
as the second argument to the folded function f.
val fold_while : ('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> 'a ‑> 'b t ‑> 'afold_while f acc as folds left on slice as until a stop condition via ('a, `Stop)
is indicated by the accumulator.
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer f as applies function f in turn to all elements of as.
It is equivalent to f as.(0); f as.(1); ...; f as.(length as - 1); ().
val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unititeri f as is like iter, but the function f is applied with the index of the element
as first argument, and the element itself as second argument.
blit as1 o1 as2 o2 len copies len elements
from slice as1, starting at element number o1, to slice as2,
starting at element number o2. It works correctly even if
as1 and as2 are the same slice, and the source and
destination chunks overlap.
Raise Invalid_argument "CCArray_slice.blit" if o1 and len do not
designate a valid subarray of as1, or if o2 and len do not
designate a valid subarray of as2.
val sorted : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp as makes a copy of as and sorts it with cmp.
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_indices cmp as returns a new array b, with the same length as as,
such that b.(i) is the index at which the i-th element of sorted cmp as
appears in as. as is not modified.
In other words, map (fun i -> as.(i)) (sort_indices cmp as) = sorted cmp as.
sort_indices yields the inverse permutation of sort_ranking.
val sort_ranking : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_ranking cmp as returns a new array b, with the same length as as,
such that b.(i) is the index at which the i-th element of as appears
in sorted cmp as. as is not modified.
In other words, map (fun i -> (sorted cmp as).(i)) (sort_ranking cmp as) = as.
sort_ranking yields the inverse permutation of sort_indices.
In the absence of duplicate elements in as, we also have
lookup_exn as.(i) (sorted as) = (sorted_ranking as).(i).
val find : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind f as returns Some y if there is an element x such
that f x = Some y. Otherwise returns None.
val findi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionfindi f as is like find, but the index of the element is also passed
to the predicate function f.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p as returns Some (i,x) where x is the i-th element of as,
and p x holds. Otherwise returns None.
lookup ~cmp x as lookups the index i of some key x in the slice as, provided as is
sorted using cmp.
None if the key x is not present, or
Some i (i the index of the key) otherwise.lookup_exn ~cmp x as is like lookup, but
x is not present.val bsearch : cmp:('a ‑> 'a ‑> int) ‑> 'a ‑> 'a t ‑> [ `All_lower | `All_bigger | `Just_after of int | `Empty | `At of int ]bsearch ~cmp x as finds the index of the object x in the slice as,
provided as is sorted using cmp. If the slice is not sorted,
the result is not specified (may raise Invalid_argument).
Complexity: O(log n) where n is the length of the slice as
(dichotomic search).
Returns
`At i if cmp as.(i) x = 0 (for some i).`All_lower if all elements of as are lower than x.`All_bigger if all elements of as are bigger than x.`Just_after i if as.(i) < x < as.(i+1).`Empty if the slice as is empty.cmp.val for_all : ('a ‑> bool) ‑> 'a t ‑> boolfor_all p [|as1; ...; asn|] checks if all elements of the slice
satisfy the predicate p. That is, it returns
(p as1) && (p as2) && ... && (p asn).
for_all2 p [|as1; ...; asn|] [|bs1; ...; bsn|] is true if each pair of elements asi bsi
satisfies the predicate p.
That is, it returns (p as1 bs1) && (p as2 bs2) && ... && (p asn bsn).
val exists : ('a ‑> bool) ‑> 'a t ‑> boolexists p [|as1; ...; asn|] is true if at least one element of
the slice satisfies the predicate p. That is, it returns
(p as1) || (p as2) || ... || (p asn).
exists2 p [|as1; ...; asn|] [|bs1; ...; bsn|] is true if any pair of elements asi bsi
satisfies the predicate p.
That is, it returns (p as1 bs1) || (p as2 bs2) || ... || (p asn bsn).
fold2 f acc as bs fold on two slices as and bs stepwise.
It computes f (... (f acc as1 bs1)...) asn bsn.
iter2 f as bs iterates on the two slices as and bs stepwise.
It is equivalent to f as0 bs0; ...; f as.(length as - 1) bs.(length bs - 1); ().
val shuffle_with : Random.State.t ‑> 'a t ‑> unitshuffle_with rs as randomly shuffles the slice as (like shuffle) but a specialized random
state rs is used to control the random numbers being produced during shuffling (for reproducibility).
val random_choose : 'a t ‑> 'a random_genrandom_choose as rs randomly chooses an element of as.
to_seq as returns a sequence of the elements of a slice as.
The input slice as is shared with the sequence and modification of it will result
in modification of the sequence.