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 10:41:26 +0200
Date: 2005-05-29T10:41:26+02:00	[thread overview]
Message-ID: <42998036$1@news.broadpark.no> (raw)
In-Reply-To: ull5yzw6g.fsf@earthlink.net

On 2005-05-29, Matthew Heaney <matthewjheaney@earthlink.net> wrote:
> Preben Randhol <randhol+valid_for_reply_from_news@pvv.org> writes:
>
>> On 2005-05-28, Matthew Heaney <matthewjheaney@earthlink.net> wrote:
>> > What do Randomize and Move do?  If you have a tentative implementation,
>> > then post it (or just mail it to me) and we can figure what is the best
>> > option for you.
>> 
>> It should be called Randomize_Container and be equivelent to the
>> Reverse_Container procedure except that it makes the order of the
>> elements random. I guess this doesn't seem to make sense for a List,
>> but I need it for a program that is asking questions from a list.
>
>
>
>
>
>> What Move does it to move element number 2 to number 4. 
>
> How is that different from Splice?

I see now. By glancing at the procedure name I thought Splice meant that
one joined say two containers (as I read the first Splice and then
skipped the rest). Didn't think it was moving an element. I
didn't read the adb file for documentation. I'll have a look now and
change the code.

> This is going to be way too expensive, since Move is implemented in
> terms of integer indexes.  You definitely want to implement Randomize in
> terms of iterators, not indexes.

Yes I can agree with you on that. And since I can use Splice I don't need
to make a new Move. I think I'm also going to make a Find where Position
is Natural in stead of Iterator_Type.

> 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?

> This should perform much better than the algorithm you posted.

Yes I'll have a look and replace my quick and dirty procedure.

Preben



  reply	other threads:[~2005-05-29  8:41 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 [this message]
2005-05-29 14:37         ` Matthew Heaney
2005-05-29 21:31           ` Preben Randhol
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