From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!d45g2000hsc.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Re: Using Ada.Containers.Vector and Limited Private types Date: Thu, 10 Jul 2008 15:59:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4c5bfeb0-daa0-45e4-82f0-eebabda565e9@d45g2000hsc.googlegroups.com> References: <8ff4c6c2-9892-463e-bdfd-1f7bfd78d607@s50g2000hsb.googlegroups.com> NNTP-Posting-Host: 134.240.241.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1215730771 798 127.0.0.1 (10 Jul 2008 22:59:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Jul 2008 22:59:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d45g2000hsc.googlegroups.com; posting-host=134.240.241.2; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; MS-RTC LM 8),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1097 Date: 2008-07-10T15:59:30-07:00 List-Id: On Jul 9, 8:16=A0pm, Dale Stanbrough wrote: > Gene wrote: > > [as did others] a solution to my problem. Thanks! > But as Dmitry pointed out, what I wrote has some portability risk. To avoid this, just copy the bits you need into your own (non-limited) data structure. with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Containers.Vectors; with Ada.Directories; use Ada.Directories; with Ada.Calendar; use Ada.Calendar; -- for comparing date/ times procedure List_By_Date is type String_Ptr_Type is access String; type File_Info_Type is record Modification_Time : Time; Simple_Name : String_Ptr_Type; -- Freed with storage pool! end record; package File_Info_Vectors is new Ada.Containers.Vectors (Positive, File_Info_Type); use File_Info_Vectors; DV : Vector; begin declare Directory : constant Filter_Type :=3D (True, False, False); Ordinary_File : constant Filter_Type :=3D (False, True, False); Results : Search_Type; -- used to hold the result of a search Directory_Entry : Directory_Entry_Type; begin Start_Search(Results, Directory =3D> Current_Directory, Pattern =3D> "", -- select all files Filter =3D> Directory or Ordinary_File); while More_Entries (Results) loop Get_Next_Entry (Results, Directory_Entry); DV.Append(File_Info_Type'( Modification_Time =3D> Modification_Time(Directory_Entry), Simple_Name =3D> new String'(Simple_Name(Directory_Entry)))); end loop; end; -- sort the entries declare function "<" (Left, Right : in File_Info_Type) return Boolean is begin return Left.Modification_Time < Right.Modification_Time; end "<"; package Dir_Vector_Sorting is new Generic_Sorting ("<"); begin Dir_Vector_Sorting.Sort (DV); end; -- display the entries declare procedure Display_Entry (C : Cursor) is begin Put_Line (Element (C).Simple_Name.all); end Display_Entry; begin DV.Iterate (Display_Entry'Access); end; end List_By_Date;