mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-05 19:00:31 -05:00
Compare commits
6 commits
a42a959d17
...
e5f038d632
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5f038d632 | ||
|
|
ab7d0fcc09 | ||
|
|
b55d3cfe6a | ||
|
|
fd1495324a | ||
|
|
765a8da876 | ||
|
|
18ffdd707b |
7 changed files with 25 additions and 2 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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 () ->
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ let max_len_b_ = 128
|
|||
|
||||
let bytes (x : bytes) =
|
||||
let h = ref fnv_offset_basis in
|
||||
for i = 0 to min max_len_b_ (Bytes.length x) do
|
||||
for i = 0 to min max_len_b_ (Bytes.length x-1) do
|
||||
(h := Int64.(mul !h fnv_prime));
|
||||
let byte = Char.code (Bytes.unsafe_get x i) in
|
||||
h := Int64.(logxor !h (of_int byte))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ t @@ fun () -> char 'c' >= 0;;
|
|||
t @@ fun () -> int 152352 = int 152352;;
|
||||
t @@ fun () -> list_comm int [ 1; 2 ] = list_comm int [ 2; 1 ];;
|
||||
t @@ fun () -> list_comm int [ 1; 2 ] <> list_comm int [ 2; 3 ];;
|
||||
t @@ fun () -> string "abcd" >= 0;;
|
||||
t @@ fun () -> string "abc" <> string "abcd";;
|
||||
|
||||
q Q.int (fun i ->
|
||||
Q.assume (i >= 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue