Module CCArray

module CCArray: sig .. end

Array utils



type 'a sequence = ('a -> unit) -> unit 
type 'a klist = unit -> [ `Cons of 'a * 'a klist | `Nil ] 
type 'a gen = unit -> 'a option 
type 'a equal = 'a -> 'a -> bool 
type 'a ord = 'a -> 'a -> int 
type 'a random_gen = Random.State.t -> 'a 

Abstract Signature


module type S = sig .. end

Arrays


type 'a t = 'a array 
include CCArray.S
val map : ('a -> 'b) -> 'a t -> 'b t
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
Map on two arrays stepwise.
Since 0.20
Raises Invalid_argument if they have distinct lengths
val rev : 'a t -> 'a t
Copy + reverse in place
Since 0.20
val filter : ('a -> bool) -> 'a t -> 'a t
Filter elements out of the array. Only the elements satisfying the given predicate will be kept.
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
Map each element into another value, or discard it
val flat_map : ('a -> 'b t) -> 'a t -> 'b array
Transform each element into an array, then flatten
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
Infix version of CCArray.flat_map
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
Infix version of CCArray.map
Since 0.8
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
Infix version of CCArray.map
Since 0.8
val except_idx : 'a t -> int -> 'a list
Remove given index, obtaining the list of the other elements
val (--) : int -> int -> int t
Range array
val (--^) : int -> int -> int t
Range array, excluding right bound
Since 0.17
val random : 'a random_gen -> 'a t random_gen
val random_non_empty : 'a random_gen -> 'a t random_gen
val random_len : int -> 'a random_gen -> 'a t random_gen

Slices

A slice is a part of an array, that requires no copying and shares its storage with the original array.

All indexing in a slice is relative to the beginning of a slice, not to the underlying array (meaning a slice is effectively like a regular array)

module Sub: sig .. end

Generic Functions


module type MONO_ARRAY = sig .. end
val sort_generic : (module CCArray.MONO_ARRAY with type elt = 'elt and type t = 'arr) ->
?cmp:('elt -> 'elt -> int) -> 'arr -> unit
Sort the array, without allocating (eats stack space though). Performance might be lower than Array.sort.
Since 0.14