mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
detail
This commit is contained in:
parent
0a6ac81276
commit
164d3ea537
1 changed files with 2 additions and 2 deletions
|
|
@ -49,10 +49,10 @@ module Make(A : ARRAY)
|
||||||
|
|
||||||
let insertion_sort_ a ~i:first ~j:last =
|
let insertion_sort_ a ~i:first ~j:last =
|
||||||
if first+1<last then (
|
if first+1<last then (
|
||||||
for i=start+1 to last-1 do
|
for i=first +1 to last-1 do
|
||||||
let j= ref i in
|
let j= ref i in
|
||||||
(* insert a[i] into slice [start… i-1] *)
|
(* insert a[i] into slice [start… i-1] *)
|
||||||
while !j > start && A.compare (get a (!j - 1)) (get a !j) > 0 do
|
while !j > first && A.compare (get a (!j - 1)) (get a !j) > 0 do
|
||||||
swap a (!j - 1) !j;
|
swap a (!j - 1) !j;
|
||||||
decr j;
|
decr j;
|
||||||
done;
|
done;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue