with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;      use Ada.Strings.Unbounded;
with Ada.Containers.Vectors;     use Ada.Containers;
 
procedure Quotes is
   package IO renames Ada.Text_IO;
   package SUIO renames Ada.Text_IO.Unbounded_IO;
   package Quote_Container is new Vectors (Natural, Unbounded_String);
   use Quote_Container;
   Quotes    : Vector;
   Input     : IO.File_Type;
   package A_Sorter is new Generic_Sorting;
begin
   IO.Open (File => Input,
            Mode => IO.In_File,
            Name => "quotes.txt");
   while not IO.End_Of_File (File => Input) loop
      Quotes.Append (New_Item => SUIO.Get_Line (File => Input));
   end loop;
   IO.Close (Input);
 
   if not A_Sorter.Is_Sorted (Container => Quotes) then
      IO.Put_Line ("We have not yet sorted the Quotes vector");
   end if;
 
   A_Sorter.Sort (Container => Quotes);
 
   if A_Sorter.Is_Sorted (Container => Quotes) then
      IO.Put_Line ("Now we have sorted the Quotes vector");
   end if;
end Quotes;
with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;      use Ada.Strings.Unbounded;
with Ada.Containers.Vectors;     use Ada.Containers;
 
procedure Quotes is
   package IO renames Ada.Text_IO;
   package SUIO renames Ada.Text_IO.Unbounded_IO;
   package Quote_Container is new Vectors (Natural, Unbounded_String);
   use Quote_Container;
   Quotes    : Vector;
   Input     : IO.File_Type;
   package A_Sorter is new Generic_Sorting;
begin
   IO.Open (File => Input,
            Mode => IO.In_File,
            Name => "quotes.txt");
   while not IO.End_Of_File (File => Input) loop
      Quotes.Append (New_Item => SUIO.Get_Line (File => Input));
   end loop;
   IO.Close (Input);
 
   if not A_Sorter.Is_Sorted (Container => Quotes) then
      IO.Put_Line ("We have not yet sorted the Quotes vector");
   end if;
 
   A_Sorter.Sort (Container => Quotes);
 
   if A_Sorter.Is_Sorted (Container => Quotes) then
      IO.Put_Line ("Now we have sorted the Quotes vector");
   end if;
 
   Quotes.Append (New_Item => To_Unbounded_String ("New stuff!"));
 
   if not A_Sorter.Is_Sorted (Container => Quotes) then
      IO.Put_Line ("The vector is no longer sorted");
   end if;
end Quotes;

Go back


Navigation