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 Newsgroups: comp.lang.ada From: Preben Randhol Subject: Re: Adding functions to generic package References: <429891d3$1@news.broadpark.no> <4298b608$1@news.broadpark.no> <42998036$1@news.broadpark.no> Organization: PVV User-Agent: slrn/0.9.8.1 (Debian) NNTP-Posting-Host: 65.80-202-208.nextgentel.com X-Original-NNTP-Posting-Host: 65.80-202-208.nextgentel.com Message-ID: <429a34bc$1@news.broadpark.no> Date: 29 May 2005 23:31:40 +0200 X-Trace: news.broadpark.no 1117402300 65.80-202-208.nextgentel.com (29 May 2005 23:31:40 +0200) Path: g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!nntp.gblx.net!nntp3.phx1!news.broadpark.no Xref: g2news1.google.com comp.lang.ada:11202 Date: 2005-05-29T23:31:40+02:00 List-Id: On 2005-05-29, Matthew Heaney wrote: > No, since J is moved (spliced) from the range [I, Back) to position I > (elements are thus moved from the back to the front). > > There are two ranges: [front, I), which stores the randomized elements, > and [I, back), which stores the non-randomized elements. > > The list starts out completely non-randomized, so [front, I) is empty > and [I, back) represents the entire list. > > During iteration, Get_Random_Iterator is used to randomly select an > element from [I, back), then it gets moved (spliced) at the end of the > randomized range (just before I). This means that every pass through > the loop, the range [front, I) grows and [I, back) shrinks. > > The iteration terminates when [I, back) has only a single element. Yes after some careful reading I understood the code. I have two different questions. How can one splice an element to 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? Reading the source code I find that the Splice function can only splice an element before a given position. 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? Best wishes Preben