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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bb7cc916bd63ab43 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!u-picardie.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Performance of element access in Vector Date: Mon, 19 Jan 2009 20:17:12 -0600 Organization: Jacob Sparre Andersen Message-ID: References: <0a8baaf0-19f7-40c0-a041-884e93fa7020@w39g2000prb.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1232417852 22738 69.95.181.76 (20 Jan 2009 02:17:32 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 20 Jan 2009 02:17:32 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news1.google.com comp.lang.ada:3447 Date: 2009-01-19T20:17:12-06:00 List-Id: "Maciej Sobczak" wrote in message news:0a8baaf0-19f7-40c0-a041-884e93fa7020@w39g2000prb.googlegroups.com... ... > A possible conclusion is that for small elements (simple numeric > types, etc.) it makes sense to access elements by index, when they are > copied from and into the container. For larger elements the benefit of > accessing element in-place can be greater than the overhead of > Update_Element. Update_Element was added to handle large element types (such as other containers) where the overhead of copying them would be prohibitive. I doubt that it could be efficient for small objects that can cheaply be passed by copy. > Just to stir the discussion a bit, a straightforward implementation of > the same test in C++ (with the same base compiler and a single -O2 > option) runs in 13s with indexed access and in 9.5s with iterators - > both are based on the use of references, which do not exist in Ada. > Not very easy to neglect this difference. What happens in C++ when the element whose reference you are using is deleted? In Ada.Containers, you'll get Program_Error if you try to do that - not a dangling pointer and havoc. Randy.