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!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread3.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> 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: Sun, 29 May 2005 22:27:45 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1117405665 24.149.57.125 (Sun, 29 May 2005 15:27:45 PDT) NNTP-Posting-Date: Sun, 29 May 2005 15:27:45 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:11205 Date: 2005-05-29T22:27:45+00:00 List-Id: Preben Randhol writes: > I have two different questions. How can one splice an element to the end > of the list? Just splice the element prior to the distinguished iterator value Back: C : Container_Type; procedure Op (I : Iterator_Type) is begin Splice (C, Before => Back (C), Iterator => I); end; Back is the iterator that designates the virtual element one-beyond-the-end of the list. > Mustn't one then Append it and Delete or call Splice twice; first > moving the element to the second last place and then move the last > place in front of it? No; just splice the element to the position before Back. See above. > Reading the source code I find that the Splice function can only > splice an element before a given position. Yes. But if you splice an element before Back, that's the same as appending it. > Another question. Why isn't there a Swap function in the library like > the one that you have in the Reverse_Container? I can make something > using two splices although a bit less effective I should imagine? Hmmm, not sure what you're asking for. Swap exchanges the internal linked lists of a pair of list containers. Reverse_Container reverses the nodes on the internal linked lists of a single list container. The list container has both of the these operations, so what operation do you need, that you want to implement using splice? Thinking about it more, I think that what you're asking for is an operation to swap a pair of nodes in the list, a la the Swap_Links operation in the Ada 200Y container library. I can add that operation, if that's what you need. (I just need to make sure I understand your request.) Note that I would probably just implement it using Splice. That's what I did in the standard container library reference implementation. -Matt