comp.lang.ada
 help / color / mirror / Atom feed
From: Preben Randhol <randhol+valid_for_reply_from_news@pvv.org>
Subject: Re: Adding functions to generic package
Date: 29 May 2005 23:31:40 +0200
Date: 2005-05-29T23:31:40+02:00	[thread overview]
Message-ID: <429a34bc$1@news.broadpark.no> (raw)
In-Reply-To: uhdgmyu6f.fsf@earthlink.net

On 2005-05-29, Matthew Heaney <matthewjheaney@earthlink.net> 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



  reply	other threads:[~2005-05-29 21:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-28 15:44 Adding functions to generic package Preben Randhol
2005-05-28 16:27 ` Matthew Heaney
2005-05-28 18:18   ` Preben Randhol
2005-05-28 18:20     ` Preben Randhol
2005-05-29  0:56     ` Matthew Heaney
2005-05-29  8:41       ` Preben Randhol
2005-05-29 14:37         ` Matthew Heaney
2005-05-29 21:31           ` Preben Randhol [this message]
2005-05-29 21:33             ` Preben Randhol
2005-05-29 22:30               ` Matthew Heaney
2005-05-30 20:45                 ` Preben Randhol
2005-05-30 22:28                   ` Marius Amado Alves
2005-06-01  1:50                     ` Matthew Heaney
2005-06-02 12:49                       ` Marius Amado Alves
2005-06-02 13:11                         ` Matthew Heaney
2005-06-01  1:41                   ` Matthew Heaney
2005-05-29 22:27             ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox