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,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!19g2000hsx.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: Containers - nontrivial element access Date: Tue, 02 Oct 2007 09:47:01 -0700 Organization: http://groups.google.com Message-ID: <1191343621.111082.202400@19g2000hsx.googlegroups.com> References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1191343621 9746 127.0.0.1 (2 Oct 2007 16:47:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Oct 2007 16:47:01 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 19g2000hsx.googlegroups.com; posting-host=66.162.65.129; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2250 Date: 2007-10-02T09:47:01-07:00 List-Id: On Oct 1, 10:34 pm, "Randy Brukardt" wrote: > Why don't you just use the Swap operation of the containers? One would > presume that it is implemented as efficiently as possible. (Surely if you > are using the indefinite version of the containers, it would just be a > pointer swap; might be a copy with the definite version of vectors, but that > couldn't be avoided as the object order is significant in that sort of > implementation.) But he's trying to swap one component of a element (which happens to be a record). The swap operation for container swaps entire elements, which is not what he wants. > That surely seems better than using explicit pointers; in most cases, > worries about efficiency are premature (and when they're not, you probably > shouldn't be using the predefined containers anyway). Agreed, you certainly don't need explicit pointers to solve thish problem. The solution I showed in my earlier post does exact what the C++ solution does; there is no effciciency issue.