summaryrefslogtreecommitdiff
path: root/quick.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2015-10-17 14:20:48 +1100
committerJed Barber <jjbarber@y7mail.com>2015-10-17 14:20:48 +1100
commit63c3043200de6b28a8c192f1b5625940435ea55e (patch)
treeab761edbbc71b2b2f28e0ef7e10b8adc58d44320 /quick.adb
parent5933f248c18914fbbce03102b340361a575eae3c (diff)
Organised source code a bit, added makefile with clean target
Diffstat (limited to 'quick.adb')
-rw-r--r--quick.adb49
1 files changed, 0 insertions, 49 deletions
diff --git a/quick.adb b/quick.adb
deleted file mode 100644
index 4586b3b..0000000
--- a/quick.adb
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-package body Quick is
-
-
- procedure Swap(A, B : in out Element_T) is
- Temp : Element_T;
- begin
- Temp := A;
- A := B;
- B := Temp;
- end Swap;
-
-
- procedure In_Place(Arr : in out Array_T) is
- Pivot, Left, Right : Index_T;
- begin
- if Arr'Length <= 1 then
- return;
- end if;
-
- Pivot := Arr'First;
- Left := Index_T'Succ(Pivot);
- Right := Arr'Last;
-
- loop
- while not (Arr(Left) > Arr(Pivot)) and Left < Arr'Last loop
- Left := Index_T'Succ(Left);
- end loop;
- while Arr(Right) > Arr(Pivot) and Right > Arr'First loop
- Right := Index_T'Pred(Right);
- end loop;
- exit when Left >= Right;
- Swap(Arr(Left), Arr(Right));
- end loop;
-
- Swap(Arr(Pivot), Arr(Right));
-
- if Right > Arr'First then
- In_Place( Arr(Arr'First .. Index_T'Pred(Right)) );
- end if;
- if Right < Arr'Last then
- In_Place( Arr(Index_T'Succ(Right) .. Arr'Last) );
- end if;
- end In_Place;
-
-
-end Quick;
-