diff options
author | Jed Barber <jjbarber@y7mail.com> | 2015-10-17 14:20:48 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2015-10-17 14:20:48 +1100 |
commit | 63c3043200de6b28a8c192f1b5625940435ea55e (patch) | |
tree | ab761edbbc71b2b2f28e0ef7e10b8adc58d44320 /comb.adb | |
parent | 5933f248c18914fbbce03102b340361a575eae3c (diff) |
Organised source code a bit, added makefile with clean target
Diffstat (limited to 'comb.adb')
-rw-r--r-- | comb.adb | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/comb.adb b/comb.adb deleted file mode 100644 index d13847c..0000000 --- a/comb.adb +++ /dev/null @@ -1,46 +0,0 @@ - - -package body Comb is - - - procedure Swap(A, B : in out Element_T) is - Temp : Element_T; - begin - Temp := A; - A := B; - B := Temp; - end Swap; - - - procedure Sort(Arr : in out Array_T) is - Swapped : Boolean; - Gap : Natural; - - Shrink : constant Float := 1.3; - begin - if Arr'Length <= 1 then - return; - end if; - - Gap := Arr'Length; - - loop - Gap := Natural(Float'Floor(Float(Gap) / Shrink)); - if Gap < 1 then - Gap := 1; - end if; - - Swapped := False; - for I in Integer range Index_T'Pos(Arr'First) .. (Index_T'Pos(Arr'Last) - Gap) loop - if Arr(Index_T'Val(I)) > Arr(Index_T'Val(I + Gap)) then - Swap( Arr(Index_T'Val(I)), Arr(Index_T'Val(I + Gap)) ); - Swapped := True; - end if; - end loop; - exit when Gap = 1 and not Swapped; - end loop; - end Sort; - - -end Comb; - |