Re: Adding functions to generic package



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