mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
fix: add shims for CCArray
This commit is contained in:
parent
f71472ad08
commit
0a201a3fa0
4 changed files with 20 additions and 11 deletions
|
|
@ -18,7 +18,7 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
|
|
||||||
(** {2 Arrays} *)
|
(** {2 Arrays} *)
|
||||||
|
|
||||||
include Array
|
include CCShimsArray_
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
|
|
||||||
|
|
@ -148,14 +148,14 @@ let sorted cmp a =
|
||||||
b
|
b
|
||||||
|
|
||||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||||
[||] (sorted Pervasives.compare [||])
|
[||] (sorted Stdlib.compare [||])
|
||||||
[|0;1;2;3;4|] (sorted Pervasives.compare [|3;2;1;4;0|])
|
[|0;1;2;3;4|] (sorted Stdlib.compare [|3;2;1;4;0|])
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
Q.(array int) (fun a -> \
|
Q.(array int) (fun a -> \
|
||||||
let b = Array.copy a in \
|
let b = Array.copy a in \
|
||||||
Array.sort Pervasives.compare b; b = sorted Pervasives.compare a)
|
Array.sort Stdlib.compare b; b = sorted Stdlib.compare a)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let sort_indices cmp a =
|
let sort_indices cmp a =
|
||||||
|
|
@ -165,8 +165,8 @@ let sort_indices cmp a =
|
||||||
b
|
b
|
||||||
|
|
||||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||||
[||] (sort_indices Pervasives.compare [||])
|
[||] (sort_indices Stdlib.compare [||])
|
||||||
[|4;2;1;0;3|] (sort_indices Pervasives.compare [|"d";"c";"b";"e";"a"|])
|
[|4;2;1;0;3|] (sort_indices Stdlib.compare [|"d";"c";"b";"e";"a"|])
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
|
|
@ -179,8 +179,8 @@ let sort_ranking cmp a =
|
||||||
sort_indices compare (sort_indices cmp a)
|
sort_indices compare (sort_indices cmp a)
|
||||||
|
|
||||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||||
[||] (sort_ranking Pervasives.compare [||])
|
[||] (sort_ranking Stdlib.compare [||])
|
||||||
[|3;2;1;4;0|] (sort_ranking Pervasives.compare [|"d";"c";"b";"e";"a"|])
|
[|3;2;1;4;0|] (sort_ranking Stdlib.compare [|"d";"c";"b";"e";"a"|])
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
|
|
@ -670,9 +670,11 @@ let sort_generic (type arr)(type elt)
|
||||||
|
|
||||||
(*$inject
|
(*$inject
|
||||||
module IA = struct
|
module IA = struct
|
||||||
|
let get = Array.get
|
||||||
|
let set = Array.set
|
||||||
|
let length = Array.length
|
||||||
type elt = int
|
type elt = int
|
||||||
type t = int array
|
type t = int array
|
||||||
include Array
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let gen_arr = Q.Gen.(array_size (1--100) small_int)
|
let gen_arr = Q.Gen.(array_size (1--100) small_int)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
external make_float : int -> float array = "caml_make_float_vect" (* compat *)
|
external make_float : int -> float array = "caml_make_float_vect" (* compat *)
|
||||||
(**/**)
|
(**/**)
|
||||||
|
|
||||||
include module type of Array
|
include module type of CCShimsArray_
|
||||||
|
|
||||||
type 'a t = 'a array
|
type 'a t = 'a array
|
||||||
(** The type for arrays *)
|
(** The type for arrays *)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
(libraries dune.configurator))
|
(libraries dune.configurator))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets CCShims_.ml CCShimsList_.ml CCShimsFormat_.ml)
|
(targets CCShims_.ml CCShimsList_.ml CCShimsArray_.ml CCShimsFormat_.ml)
|
||||||
(deps ./mkshims.exe)
|
(deps ./mkshims.exe)
|
||||||
(action (run ./mkshims.exe)))
|
(action (run ./mkshims.exe)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ let shims_list_pre_408 = "
|
||||||
"
|
"
|
||||||
let shims_list_post_408 = "include List"
|
let shims_list_post_408 = "include List"
|
||||||
|
|
||||||
|
let shims_array_pre_408 = "
|
||||||
|
include Array
|
||||||
|
type +'a t = 'a array
|
||||||
|
"
|
||||||
|
let shims_array_post_408 = "include Array"
|
||||||
|
|
||||||
let write_file f s =
|
let write_file f s =
|
||||||
let out = open_out f in
|
let out = open_out f in
|
||||||
output_string out s; flush out; close_out out
|
output_string out s; flush out; close_out out
|
||||||
|
|
@ -51,5 +57,6 @@ let () =
|
||||||
let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in
|
let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in
|
||||||
write_file "CCShims_.ml" (if (major, minor) >= (4,8) then shims_post_408 else shims_pre_408);
|
write_file "CCShims_.ml" (if (major, minor) >= (4,8) then shims_post_408 else shims_pre_408);
|
||||||
write_file "CCShimsList_.ml" (if (major, minor) >= (4,8) then shims_list_post_408 else shims_list_pre_408);
|
write_file "CCShimsList_.ml" (if (major, minor) >= (4,8) then shims_list_post_408 else shims_list_pre_408);
|
||||||
|
write_file "CCShimsArray_.ml" (if (major, minor) >= (4,8) then shims_array_post_408 else shims_array_pre_408);
|
||||||
write_file "CCShimsFormat_.ml" (if (major, minor) >= (4,8) then shims_fmt_post_408 else shims_fmt_pre_408);
|
write_file "CCShimsFormat_.ml" (if (major, minor) >= (4,8) then shims_fmt_post_408 else shims_fmt_pre_408);
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue