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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f2690a5e963b61b6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!newsfeed1.swip.net!swipnet!newsfeed.sunet.se!news01.sunet.se!uninett.no!feed.news.tiscali.de!blackbush.cw.net!cw.net!news.rh-tec.net!news.germany.com!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <1120575076.876798.108220@g44g2000cwa.googlegroups.com> <1120583470.429264.325450@g43g2000cwa.googlegroups.com> <42cb8d21$0$22761$9b4e6d93@newsread2.arcor-online.net> <42cd064c$0$10817$9b4e6d93@newsread4.arcor-online.net> <42cda8c4$0$22780$9b4e6d93@newsread2.arcor-online.net> <1u3hh2597i4ne$.1ryetugksbmus.dlg@40tude.net> <42ce5856$0$22762$9b4e6d93@newsread2.arcor-online.net> <1o398w3zo2zf1$.f1f7tukylueo$.dlg@40tude.net> Date: Tue, 12 Jul 2005 10:44:25 +0200 Message-ID: <1qm62kbb1qwnl.ywnvsfug5p88.dlg@40tude.net> NNTP-Posting-Date: 12 Jul 2005 10:44:25 MEST NNTP-Posting-Host: 8c4175c3.newsread4.arcor-online.net X-Trace: DXC=kQEO0B On Mon, 11 Jul 2005 13:38:56 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:nmv39ipirsbg$.1or742g96p5km.dlg@40tude.net... >>> The abstract view of iteration is that it produces *every* element of the >>> container, and no others, in *some* unspecified order. That applies both the >>> the passive iterator Iterate and the cursor based routines like Next. >> >> An unspecified order is still an order. What could be said about that >> unspecified order? > > Nothing. That's the meaning of "unspecified"! The implementation can use any > convinient order. What about Prev (Next (X)) /= X? >>> Of course, specific containers do require a specific order, and *then* you >>> can rely upon it. But not in a generic algorithm. >> >> A generic algorithm is just a class-wide procedure. The problem is the >> contract of the class. If iteration is in the contract, then its behavior >> must be defined. So that the correctness of the algorithm would be >> independent on any possible implementation. If it is outside, then there >> must be no [easy] way to use it. > > For a passive iterator, the contract is that each element is visited exactly > once, in an unspecified order. Signficant changes to the container during a > passive iterator are *not* allowed (they raise Program_Error). Thus, the > order is irrelevant. It is not, you just have replaced "changes that preserve the iteration order and the membership" with "insignificant changes". Then passive, one-way iterators are more or less acceptable. Cursors are much more questionable. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de