module ArrayExtras: sig end
Searching
|
val find_index : ('a -> bool) -> 'a array -> intfind_index f arr Returns the index of the first element in the
array that satisfies the predicateNot_found if f never returns trueval find_index_from : ('a -> bool) -> 'a array -> int -> intNot_found if f never returns true
Searching sorted arrays
|
These modules provide efficient O(lg n) searching of sorted
arrays. Rather than having every function take a comparison-function
argument, functors are used.
module type Comparable = sig endmodule Sorted: functor (Comp : Comparable) -> sig end
Stepping through elements
|
val ensure : ('a -> bool) -> 'a array -> boolensure f a returns true if f is true for all elements in
a. It stops after the first false result, making it more efficient
than Array.fold_left for validation.val ensure_range : ('a -> bool) -> 'a array -> int -> int -> boolensure_range f a i len applies f to the len-gth elements in a
starting at index i and returns true if f is true for all the
elements, otherwise false.
Transformation
|
val swap : 'a array -> int -> int -> unitval rev : 'a array -> unit
Stacks
|
val pop : 'a array -> 'a * 'a arrayval push : 'a -> 'a array -> 'a array
Sorting
|
val munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b arrayval stable_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b arrayval fast_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b array