Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Using Ada.C...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 18 Topic 5799 of 5966
Post > Topic >>

Re: Using Ada.Containers.Vector and Limited Private types

by "Dmitry A. Kazakov" <mailbox@[EMAIL PROTECTED] > Jul 12, 2008 at 09:53 AM

On Thu, 10 Jul 2008 15:59:30 -0700 (PDT), Gene wrote:
 
> 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);

I am using a different design in such cases, which are a kind of cached
data store with sorted items.

I would make a descriptor type containing all data of an item:

   type File_Info (Length : Natural) is record
      Modification_Time : Time;
      Simple_Name : String (1..Length);
      ...
   end record;

File_Info can be allocated in an arena or mark-and-release pool. That is
no
matter. Then comparison operations are defined on the pointers rather than
the descriptors:

   type File_Info_By_Date is access all File_Info;
   function "<" (Left, Right : File_Info_By_Date) return Boolean;

   type File_Info_By_Name is access all File_Info;
   function "<" (Left, Right : File_Info_By_Name) return Boolean;

   type File_Info_By_Size is access all File_Info;
   function "<" (Left, Right : File_Info_By_Size) return Boolean;

etc.

Then I would create ordered sets of File_Info_By_Date, File_Info_By_Name
and so on. All this I put into a controlled object which takes care about
inserting and removing items. Indexes of pointers are kept sorted. This is
exactly the design I used for a persistency layer.

(I don't use Ada.Containers, but I think this approach should work with
them too.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
 




 18 Posts in Topic:
Using Ada.Containers.Vector and Limited Private types
Dale Stanbrough <MrNoS  2008-07-05 11:53:38 
Re: Using Ada.Containers.Vector and Limited Private types
george.priv@[EMAIL PROTEC  2008-07-05 08:42:41 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-06 11:09:58 
Re: Using Ada.Containers.Vector and Limited Private types
"Dmitry A. Kazakov&q  2008-07-06 21:18:17 
Re: Using Ada.Containers.Vector and Limited Private types
Dale Stanbrough <MrNoS  2008-07-10 00:16:06 
Re: Using Ada.Containers.Vector and Limited Private types
"Dmitry A. Kazakov&q  2008-07-10 09:31:52 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-07 06:29:16 
Re: Using Ada.Containers.Vector and Limited Private types
"Dmitry A. Kazakov&q  2008-07-07 16:15:11 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-07 11:39:52 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-10 15:59:30 
Re: Using Ada.Containers.Vector and Limited Private types
"Jeffrey R. Carter&q  2008-07-11 22:06:58 
Re: Using Ada.Containers.Vector and Limited Private types
"Dmitry A. Kazakov&q  2008-07-12 09:53:33 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-11 19:45:47 
Re: Using Ada.Containers.Vector and Limited Private types
"Jeffrey R. Carter&q  2008-07-12 04:41:31 
Re: Using Ada.Containers.Vector and Limited Private types
"Dmitry A. Kazakov&q  2008-07-12 10:02:07 
Re: Using Ada.Containers.Vector and Limited Private types
Gene <gene.ressler@[EM  2008-07-13 08:30:23 
Re: Using Ada.Containers.Vector and Limited Private types
"Jeffrey R. Carter&q  2008-07-13 18:10:08 
Re: Using Ada.Containers.Vector and Limited Private types
Simon Wright <simon.j.  2008-07-16 22:23:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 14:05:42 CST 2008.