Re: Adding functions to generic package
- From: Matthew Heaney <matthewjheaney@xxxxxxxxxxxxx>
- Date: Sun, 29 May 2005 14:37:44 GMT
Preben Randhol <randhol+valid_for_reply_from_news@xxxxxxx> writes:
> > Get_Random_Iterator returns an iterator (J) in the range [I, Back):
>
> Not sure I understand this. Wouldn't this mean that the randomisation
> only will be able to put element further back in the list?
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.
.
- Follow-Ups:
- Re: Adding functions to generic package
- From: Preben Randhol
- Re: Adding functions to generic package
- References:
- Adding functions to generic package
- From: Preben Randhol
- Re: Adding functions to generic package
- From: Matthew Heaney
- Re: Adding functions to generic package
- From: Preben Randhol
- Re: Adding functions to generic package
- From: Matthew Heaney
- Re: Adding functions to generic package
- From: Preben Randhol
- Adding functions to generic package
- Prev by Date: Re: Adding functions to generic package
- Next by Date: Re: Adding functions to generic package
- Previous by thread: Re: Adding functions to generic package
- Next by thread: Re: Adding functions to generic package
- Index(es):