module ArrayExtras: sig end
Searching
|
val find_index : ('a -> bool) -> 'a array -> int
find_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 -> int
Not_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 end
module Sorted: functor (Comp : Comparable) -> sig end
Stepping through elements
|
val ensure : ('a -> bool) -> 'a array -> bool
ensure 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 -> bool
ensure_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 -> unit
val rev : 'a array -> unit
Stacks
|
val pop : 'a array -> 'a * 'a array
val push : 'a -> 'a array -> 'a array
Sorting
|
val munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b array
val stable_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b array
val fast_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b array -> 'b array