mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
CCArray.Sub.of_slice; bugfix in reverse_in_place
This commit is contained in:
parent
4d2fa4ea4c
commit
90239f2c3e
2 changed files with 10 additions and 3 deletions
|
|
@ -110,10 +110,10 @@ let rec _foldi f acc a i j =
|
||||||
let _reverse_in_place a i j =
|
let _reverse_in_place a i j =
|
||||||
if i=j then ()
|
if i=j then ()
|
||||||
else
|
else
|
||||||
for k = i to j/2 do
|
for k = i to (j-1)/2 do
|
||||||
let t = a.(k) in
|
let t = a.(k) in
|
||||||
a.(k) <- a.(j-k);
|
a.(k) <- a.(j-1-k);
|
||||||
a.(j-k) <- t;
|
a.(j-1-k) <- t;
|
||||||
done
|
done
|
||||||
|
|
||||||
let rec _equal eq a1 i1 j1 a2 i2 j2 =
|
let rec _equal eq a1 i1 j1 a2 i2 j2 =
|
||||||
|
|
@ -350,6 +350,8 @@ module Sub = struct
|
||||||
if i+len > Array.length arr then invalid_arg "Array.Sub.make";
|
if i+len > Array.length arr then invalid_arg "Array.Sub.make";
|
||||||
{ arr; i; j=i+len; }
|
{ arr; i; j=i+len; }
|
||||||
|
|
||||||
|
let of_slice (arr,i,len) = make arr i ~len
|
||||||
|
|
||||||
let full arr = { arr; i=0; j=Array.length arr; }
|
let full arr = { arr; i=0; j=Array.length arr; }
|
||||||
|
|
||||||
let underlying a = a.arr
|
let underlying a = a.arr
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,11 @@ module Sub : sig
|
||||||
(** Create a slice.
|
(** Create a slice.
|
||||||
@raise Invalid_argument if the slice isn't valid *)
|
@raise Invalid_argument if the slice isn't valid *)
|
||||||
|
|
||||||
|
val of_slice : ('a array * int * int) -> 'a t
|
||||||
|
(** Make a sub-array from a triple [(arr, i, len)] where [arr] is the array,
|
||||||
|
[i] the offset in [arr], and [len] the number of elements of the slice.
|
||||||
|
@raise Invalid_argument if the slice isn't valid (See {!make}) *)
|
||||||
|
|
||||||
val full : 'a array -> 'a t
|
val full : 'a array -> 'a t
|
||||||
(** Slice that covers the full array *)
|
(** Slice that covers the full array *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue