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> 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: <42998036$1@news.broadpark.no> Date: 29 May 2005 10:41:26 +0200 X-Trace: news.broadpark.no 1117356086 65.80-202-208.nextgentel.com (29 May 2005 10:41:26 +0200) Path: g2news1.google.com!news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!nntp.gblx.net!nntp3.phx1!news.broadpark.no Xref: g2news1.google.com comp.lang.ada:11200 Date: 2005-05-29T10:41:26+02:00 List-Id: On 2005-05-29, Matthew Heaney wrote: > Preben Randhol writes: > >> On 2005-05-28, Matthew Heaney 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