OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gnat.dg/] [sort1.adb] - Rev 316

Go to most recent revision | Compare with Previous | Blame | View Log

with GNAT.Heap_Sort_G;
function sort1 (S : String) return String is
   Result : String (1 .. S'Length) := S;
   Temp : Character;
 
   procedure Move (From : Natural; To : Natural) is 
   begin
      if From = 0 then Result (To) := Temp;
      elsif To = 0 then Temp := Result (From);
      else Result (To) := Result (From);                       
              end if;                                          
   end Move; 
 
   function Lt (Op1, Op2 : Natural) return Boolean is
   begin
      if Op1 = 0 then return Temp < Result (Op2);
      elsif Op2 = 0 then return Result (Op1) < Temp;
      else return Result (Op1) < Result (Op2);
      end if;
   end Lt;
 
   package SP is new GNAT.Heap_Sort_G (Move, Lt);
 
begin
   SP.Sort (S'Length);
   return Result;
end;
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.