Ppx_hardcaml_runtime0.Iarrayinclude module type of struct include Core.Iarray endtype 'a t = 'a Base.Iarray.tinclude sig ... endinclude Bin_prot.Binable.S1__local with type 'a t := 'a Base.Iarray.tval bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.tinclude sig ... endval bin_size_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Size.sizer1val bin_write_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Write.writer1val bin_read_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Read.reader1val __bin_read_t__ : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Read.vtag_reader1val bin_writer_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Type_class.S1.writerval bin_reader_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Type_class.S1.readerval bin_t : 'a. ('a, 'a Base.Iarray.t) Bin_prot.Type_class.S1.tval quickcheck_generator :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Generator.t ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Generator.t @@ portableval quickcheck_generator__portable :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Generator.t @ portable ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Generator.t @ portable @@ portableval quickcheck_observer :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Observer.t ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Observer.t @@ portableval quickcheck_observer__portable :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Observer.t @ portable ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Observer.t @ portable @@ portableval quickcheck_shrinker :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t @@ portableval quickcheck_shrinker__portable :
'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t @ portable ->
'a Base.Iarray.t Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t @ portable @@ portableinclude Typerep_lib.Typerepable.S1 with type 'a t := 'a Base.Iarray.tval typerep_of_t :
'a Typerep_lib.Std_internal.Typerep.t ->
'a Base.Iarray.t Typerep_lib.Std_internal.Typerep.t @@ portableval typename_of_t :
'a Typerep_lib.Typename.t ->
'a Base.Iarray.t Typerep_lib.Typename.t @@ portableinclude sig ... endval sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.tval sexp_of_t__stack :
'a. ('a @ local -> Sexplib0.Sexp.t @ local) ->
'a t @ local ->
Sexplib0.Sexp.t @ localval t_of_sexp : 'a. (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a tval t_sexp_grammar :
'a. 'a Sexplib0.Sexp_grammar.t ->
'a t Sexplib0.Sexp_grammar.t @@ portableinclude sig ... endinclude Ppx_hash_lib.Hashable.S1_any with type 'a t := 'a tval hash_fold_t : 'a Ppx_hash_lib.hash_fold -> 'a t Ppx_hash_lib.hash_foldStandard interfaces
include Base.Binary_searchable.S1__local with type 'a t := 'a tSee Binary_search.binary_search in binary_search.ml
val binary_search :
?pos:int ->
?len:int ->
'a t ->
compare:('a -> ('key -> int) @ local) @ local ->
([ `Last_strictly_less_than
| `Last_less_than_or_equal_to
| `Last_equal_to
| `First_equal_to
| `First_greater_than_or_equal_to
| `First_strictly_greater_than ] ->
('key ->
int option @ local) @ local) @ localSee Binary_search.binary_search_segmented in binary_search.ml
val binary_search_segmented :
?pos:int ->
?len:int ->
'a t ->
segment_of:('a -> [ `Left | `Right ]) @ local ->
([ `Last_on_left | `First_on_right ] ->
int option @ local) @ localinclude Base.Indexed_container.S1_with_creators__stack with type 'a t := 'a tinclude Base.Container.S1__''value''__stack with type 'a t := 'a tinclude sig ... endinclude Base.Container.Generic_types__''value''
with type ('a, _, _) t := 'a t
with type 'a elt := 'aThese are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.
val iteri : 'a 'p1 'p2. 'a t -> f:(int -> ('a -> unit) @ local) @ local -> unitval existsi :
'a 'p1 'p2. 'a t ->
f:(int -> ('a -> bool) @ local) @ local ->
boolval for_alli :
'a 'p1 'p2. 'a t ->
f:(int -> ('a -> bool) @ local) @ local ->
boolval counti : 'a 'p1 'p2. 'a t -> f:(int -> ('a -> bool) @ local) @ local -> intval iteri_until :
'a 'p1 'p2 'final. 'a t ->
f:
(int -> ('a -> (unit, 'final) Base.Container.Continue_or_stop.t) @ local) @ local ->
(finish:(int -> 'final) @ local ->
'final) @ localval find_mapi :
'a 'p1 'p2 'b. 'a t ->
f:(int -> ('a -> 'b option) @ local) @ local ->
'b optionval foldi_until :
'a 'p1 'p2 'acc 'final. 'a t ->
init:'acc ->
f:
(int ->
('acc ->
('a ->
('acc, 'final) Base.Container.Continue_or_stop.t) @ local) @ local) @ local ->
(finish:(int -> ('acc -> 'final) @ local) @ local ->
'final) @ localval findi :
'a 'p1 'p2. 'a t ->
f:(int -> ('a -> bool) @ local) @ local ->
(int * 'a) optioninclude Base.Container.S1_with_creators__''value''__stack
with type 'a t := 'a tinclude sig ... endval is_empty : 'a 'p1 'p2. 'a t @ local -> boolval iter : 'a 'p1 'p2. 'a t -> f:('a -> unit) @ local -> unititer must allow exceptions raised in f to escape, terminating the iteration cleanly. The same holds for all functions below taking an f.
val exists : 'a 'p1 'p2. 'a t -> f:('a -> bool) @ local -> boolReturns true if and only if there exists an element for which the provided function evaluates to true. This is a short-circuiting operation.
val for_all : 'a 'p1 'p2. 'a t -> f:('a -> bool) @ local -> boolReturns true if and only if the provided function evaluates to true for all elements. This is a short-circuiting operation.
val count : 'a 'p1 'p2. 'a t -> f:('a -> bool) @ local -> intReturns the number of elements for which the provided function evaluates to true.
val find : 'a 'p1 'p2. 'a t -> f:('a -> bool) @ local -> 'a Option.tReturns as an option the first element for which f evaluates to true.
val to_list : 'a 'p1 'p2. 'a t -> 'a listval min_elt :
'a 'p1 'p2. 'a t ->
compare:('a -> ('a -> int) @ local) @ local ->
'a Option.tReturns a min (resp. max) element from the collection using the provided compare function. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold. Returns None iff the collection is empty.
val max_elt :
'a 'p1 'p2. 'a t ->
compare:('a -> ('a -> int) @ local) @ local ->
'a Option.tval sum :
'a 'sum 'p1 'p2. (module Base.Container.Summable with type t = 'sum) ->
'a t ->
f:('a -> 'sum) @ local ->
'sumReturns the sum of f i for all i in the container. The order in which the elements will be summed is unspecified.
val iter_until :
'a 'p1 'p2 'final. 'a t ->
f:('a -> (unit, 'final) Base.Container.Continue_or_stop.t) @ local ->
(finish:(unit -> 'final) @ local ->
'final) @ localiter_until t ~f ~finish is a short-circuiting version of iter. If f returns Stop x the computation ceases and returns x. If f always returns Continue () the final result is computed by finish.
val fold_result :
'a 'p1 'p2 'acc 'e. 'a t ->
init:'acc ->
f:('acc -> ('a -> ('acc, 'e) Result.t) @ local) @ local ->
('acc, 'e) Result.tfold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.
val find_map :
'a 'p1 'p2 'b. 'a t ->
f:('a -> 'b Option.t) @ local ->
'b Option.tReturns the first evaluation of f that returns Some, and returns None if there is no such element.
val fold_until :
'a 'p1 'p2 'acc 'final. 'a t ->
init:'acc ->
f:
('acc -> ('a -> ('acc, 'final) Base.Container.Continue_or_stop.t) @ local) @ local ->
(finish:('acc -> 'final) @ local ->
'final) @ localfold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.
Example:
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3val mem :
'a 'p1 'p2. 'a t ->
'a ->
equal:('a -> ('a -> bool) @ local) @ local ->
boolChecks whether the provided element is there, using equal.
include sig ... endval of_list : 'a 'p1 'p2. 'a list -> 'a tE.g., append (of_list [a; b]) (of_list [c; d; e]) is of_list [a; b; c; d; e]
Concatenates a nested container. The elements of the inner containers are concatenated together in order to give the result.
filter t ~f returns all the elements of t that satisfy the predicate f.
map f (of_list [a1; ...; an]) applies f to a1, a2, ..., an, in order, and builds a result equivalent to of_list [f a1; ...; f an].
filter_map t ~f applies f to every x in t. The result contains every y for which f x returns Some y.
concat_map t ~f is equivalent to concat (map t ~f).
partition_map t ~f partitions t according to f.
val to_array : 'a. 'a t -> 'a arrayval of_array : 'a. 'a array -> 'a tinclude Base.Container.Generic_types__''value''
with type ('a, _, _) t := 'a t
with type 'a elt := 'apartitioni_tf t ~f is like partition_tf. Additionally, it passes the index as an argument.
mapi is like map. Additionally, it passes in the index of each element as the first argument to the mapped function.
filter_mapi is like filter_map. Additionally, it passes in the index of each element as the first argument to the mapped function.
concat_mapi t ~f is like concat_map. Additionally, it passes the index as an argument.
include Base.Invariant.S1 with type 'a t := 'a tval invariant : ('a -> unit) -> 'a t -> unitOperators
module O = Core.Iarray.Oval (.:()) : 'a. 'a Basement.Stdlib_iarray_labels.t -> int -> 'aAn alias for get.
Indexing
val length : 'a. 'a t @ immutable -> intval get : 'a. 'a t -> int -> 'aval get_opt : 'a t -> int -> 'a optionval unsafe_get : 'a. 'a t -> int -> 'aval last_exn : 'a t -> 'aFunctional update
Constructors
val empty : _ tval singleton : 'a -> 'a tval create :
len:int ->
'a ->
mutate:('a array @ local -> unit) @ local ->
'a Basement.Stdlib_iarray_labels.tval init : 'a. int -> f:(int -> 'a) @ local -> 'a tConversions
val of_sequence : 'a Base.Sequence.t -> 'a tval to_sequence : 'a t -> 'a Base.Sequence.tval of_list_rev : 'a list -> 'a tval of_list_map : 'a list -> f:('a -> 'b) @ local -> 'b tval of_list_mapi : 'a list -> f:(int -> ('a -> 'b) @ local) @ local -> 'b tval of_list_rev_map : 'a list -> f:('a -> 'b) @ local -> 'b tSubsequences
split_n t n returns a pair of iarrays (first, second) where first contains the first n elements of t and second contains the remaining elements.
n >= length t, returns (t, empty).n <= 0, returns (empty, t).chunks_of t ~length returns an iarray of iarrays whose concatenation is equal to the original iarray. Every iarray has length elements, except for possibly the last iarray, which may have fewer. chunks_of raises if length <= 0.
Reordering
val is_sorted : 'a t -> compare:('a -> ('a -> int) @ local) @ local -> boolval is_sorted_strictly :
'a t ->
compare:('a -> ('a -> int) @ local) @ local ->
boolCombining elements
val reduce : 'a t -> f:('a -> ('a -> 'a) @ local) @ local -> 'a optionval reduce_exn : 'a t -> f:('a -> ('a -> 'a) @ local) @ local -> 'aval combine_errors : 'a Base.Or_error.t t -> 'a t Base.Or_error.tval combine_errors_unit : unit Base.Or_error.t t -> unit Base.Or_error.tval fold :
'a 'acc. 'a t ->
init:'acc ->
f:('acc -> ('a -> 'acc) @ local) @ local ->
'accval foldi :
'a 'acc. 'a t ->
init:'acc ->
f:(int -> ('acc -> ('a -> 'acc) @ local) @ local) @ local ->
'accval fold_right :
'a 'acc. 'a t ->
init:'acc ->
f:('a -> ('acc -> 'acc) @ local) @ local ->
'accMultiple arrays
Random elements
val random_element : ?random_state:Base.Random.State.t -> 'a t -> 'a optionval random_element_exn : ?random_state:Base.Random.State.t -> 'a t -> 'aBlit operations
module Of_array = Core.Iarray.Of_arraymodule To_array = Core.Iarray.To_arraymodule Local = Core.Iarray.LocalOperations for local iarrays.
module Unique = Core.Iarray.UniqueOperations for unique iarrays
Unsafe conversions
Immutable arrays can be converted to and from mutable arrays, as they can have the same representation. One must be careful not to modify the mutable array sharing a representation with an immutable array at any time when both are reachable. Doing so violates the invariants of the immutable array. The OCaml compiler might rely on these invariants when compiling or optimizing code that uses immutable arrays.
val unsafe_to_array__promise_no_mutation : 'a. 'a t -> 'a arrayval unsafe_of_array__promise_no_mutation : 'a. 'a array -> 'a tmodule Stable = Core.Iarray.Stable