Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,9 +0,0 @@
-----------------------------------------------------------------------
-- Generic Quick_Sort procedure
-----------------------------------------------------------------------
generic
type Element is private;
type Index is (<>);
type Element_Array is array(Index range <>) of Element;
with function "<" (Left, Right : Element) return Boolean is <>;
procedure Quick_Sort(A : in out Element_Array);

View file

@ -1,44 +0,0 @@
-----------------------------------------------------------------------
-- Generic Quick_Sort procedure
-----------------------------------------------------------------------
procedure Quick_Sort (A : in out Element_Array) is
procedure Swap(Left, Right : Index) is
Temp : Element := A (Left);
begin
A (Left) := A (Right);
A (Right) := Temp;
end Swap;
begin
if A'Length > 1 then
declare
Pivot_Value : Element := A (A'First);
Right : Index := A'Last;
Left : Index := A'First;
begin
loop
while Left < Right and not (Pivot_Value < A (Left)) loop
Left := Index'Succ (Left);
end loop;
while Pivot_Value < A (Right) loop
Right := Index'Pred (Right);
end loop;
exit when Right <= Left;
Swap (Left, Right);
Left := Index'Succ (Left);
Right := Index'Pred (Right);
end loop;
if Right = A'Last then
Right := Index'Pred (Right);
Swap (A'First, A'Last);
end if;
if Left = A'First then
Left := Index'Succ (Left);
end if;
Quick_Sort (A (A'First .. Right));
Quick_Sort (A (Left .. A'Last));
end;
end if;
end Quick_Sort;

View file

@ -1,32 +0,0 @@
with Ada.Text_Io;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Quick_Sort;
procedure Sort_Test is
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
type Sales is array (Days range <>) of Float;
procedure Sort_Days is new Quick_Sort(Float, Days, Sales);
procedure Print (Item : Sales) is
begin
for I in Item'range loop
Put(Item => Item(I), Fore => 5, Aft => 2, Exp => 0);
end loop;
end Print;
Weekly_Sales : Sales := (Mon => 300.0,
Tue => 700.0,
Wed => 800.0,
Thu => 500.0,
Fri => 200.0,
Sat => 100.0,
Sun => 900.0);
begin
Print(Weekly_Sales);
Ada.Text_Io.New_Line(2);
Sort_Days(Weekly_Sales);
Print(Weekly_Sales);
end Sort_Test;