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,7e81a70d49e1dad0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Adding functions to generic package References: <429891d3$1@news.broadpark.no> <4298b608$1@news.broadpark.no> <42998036$1@news.broadpark.no> <429a34bc$1@news.broadpark.no> <429a3514$1@news.broadpark.no> <429b7b62$1@news.broadpark.no> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 01 Jun 2005 01:50:02 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1117590602 24.149.57.125 (Tue, 31 May 2005 18:50:02 PDT) NNTP-Posting-Date: Tue, 31 May 2005 18:50:02 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:11212 Date: 2005-06-01T01:50:02+00:00 List-Id: Marius Amado Alves writes: > > I guess it must be: > > > > procedure Swap (Container : in out Container_Type; L,R : > > Iterator_Type); > > > > as I want the Swap to Swap say element in position 4 with element in > > postion 2 in the list but by using iterators to point at them. > > No need. Cursors know their containers. No, this is wrong. In Charles, iterators do *not* carry a pointer to container (they only hold a pointer to the node containing the element), and so (in Charles) you'd need to pass the container too. But moving a node can change the value of the head and foot pointers, which are part of the representation of the container type, so you need to pass the container anyway. The rule is that whenever an operation manipulates the container object itself, the container is passed a parameter. Mario is probably thinking of the Ada 2005 standard container library. Cursor types do indeed hold a pointer to the container, in addition to the node. However, the rule about manipulation of the container object still applies (what a coincidence!), so the container is passed as a parameter too (see the operation named Swap_Links). -Matt