blob: 863fb8e6169b5a52cff6fe745c17f09af123cc8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package body Insertion is
procedure Sort(Arr : in out Array_T) is
Place : Index_T;
Temp : Element_T;
begin
if Arr'Length <= 1 then
return;
end if;
for I in Index_T range Index_T'Succ(Arr'First) .. Arr'Last loop
if Arr(Index_T'Pred(I)) > Arr(I) then
Place := I;
while Place /= Arr'First and then Arr(Index_T'Pred(Place)) > Arr(I) loop
Place := Index_T'Pred(Place);
end loop;
Temp := Arr(I);
Arr(Index_T'Succ(Place) .. I) := Arr(Place .. Index_T'Pred(I));
Arr(Place) := Temp;
end if;
end loop;
end Sort;
end Insertion;
|