Compare commits

...

5 commits

Author SHA1 Message Date
猗露
c06b5a57db
Merge fd1495324a into 14ad490c7e 2025-11-14 22:18:41 +07:00
István Donkó
14ad490c7e fix: insert missing symbol into range doc comments
Some checks failed
Build and Test / build (push) Has been cancelled
Build and Test / format (push) Has been cancelled
2025-10-27 12:03:46 -04:00
猗露
fd1495324a add benchmark 2025-01-30 10:07:48 +08:00
猗露
765a8da876 update docs 2025-01-30 09:37:57 +08:00
猗露
18ffdd707b add CCArray.of_iter 2025-01-29 11:43:38 +08:00
7 changed files with 24 additions and 3 deletions

View file

@ -1153,12 +1153,14 @@ module Iter_ = struct
let bench_to_array n =
let iter () = Iter.to_array Iter.(1 -- n)
and gen () = Gen.to_array Gen.(1 -- n)
and oseq () = OSeq.to_array OSeq.(1 -- n) in
and oseq () = OSeq.to_array OSeq.(1 -- n)
and of_iter () = CCArray.of_iter Iter.(1 -- n) in
B.throughputN 3 ~repeat
[
"iter.to_array", iter, ();
"gen.to_array", gen, ();
"oseq.to_array", oseq, ();
"ccarray.of_iter", of_iter, ();
]
let bench_cons n =

View file

@ -466,6 +466,12 @@ let to_seq a =
let to_iter a k = iter k a
let of_iter (i : 'a iter) : 'a array =
let open CCVector in
let vec = create () in
i (push vec);
to_array vec
let to_gen a =
let k = ref 0 in
fun () ->

View file

@ -240,6 +240,11 @@ val to_iter : 'a t -> 'a iter
in modification of the iterator.
@since 2.8 *)
val of_iter : 'a iter -> 'a t
(** [of_iter iter] builds a array from a given [iter].
In the result, elements appear in the same order as they did in the source [iter].
@since NEXT_RELEASE *)
val to_seq : 'a t -> 'a Seq.t
(** [to_seq a] returns a [Seq.t] of the elements of an array [a].
The input array [a] is shared with the sequence and modification of it will result

View file

@ -248,6 +248,11 @@ val to_iter : 'a t -> 'a iter
in modification of the iterator.
@since 2.8 *)
val of_iter : 'a iter -> 'a t
(** [of_iter iter] builds a array from a given [iter].
In the result, elements appear in the same order as they did in the source [iter].
@since NEXT_RELEASE *)
val to_seq : 'a t -> 'a Seq.t
(** [to_seq a] returns a [Seq.t] of the elements of an array [a].
The input array [a] is shared with the sequence and modification of it will result

View file

@ -183,7 +183,7 @@ val ( -- ) : int -> int -> int t
[a] and [b] (therefore, never empty). *)
val ( --^ ) : int -> int -> int t
(** [a -- b] is the integer range from [a] to [b], where [b] is excluded. *)
(** [a --^ b] is the integer range from [a] to [b], where [b] is excluded. *)
(** {2 Operations on two Collections} *)

View file

@ -139,7 +139,7 @@ val ( -- ) : int -> int -> int t
@since 0.10 *)
val ( --^ ) : int -> int -> int t
(** [a -- b] is the integer range from [a] to [b], where [b] is excluded.
(** [a --^ b] is the integer range from [a] to [b], where [b] is excluded.
@since 0.17 *)
val pp : 'a printer -> 'a t printer

View file

@ -309,3 +309,6 @@ q ~count:300 arr_arbitrary (fun a ->
Array.sort CCInt.compare a1;
sort_generic (module IA) ~cmp:CCInt.compare a2;
a1 = a2)
;;
q Q.(array int) (fun a -> of_iter (to_iter a) = a)