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,fe5e779eaf4ecf02 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!grolier!rain.fr!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Date: Fri, 20 Jun 2008 16:49:44 +0200 From: Pascal Obry Organization: Home - http://www.obry.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to loop (elegant) throug a vector ? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <485bc388$0$891$ba4acef3@news.orange.fr> NNTP-Posting-Date: 20 Jun 2008 16:49:44 CEST NNTP-Posting-Host: 82.124.66.220 X-Trace: 1213973384 news.orange.fr 891 82.124.66.220:1251 X-Complaints-To: abuse@orange.fr Xref: g2news1.google.com comp.lang.ada:782 Date: 2008-06-20T16:49:44+02:00 List-Id: Reinert Korsnes a �crit : > Could anybody suggest improvements for the three > last lines in the code? A solution using the Iterate routine: procedure Do_Something (P : X_t.Cursor) is E : constant Item_T := Element (P); begin ... end Do_Something; X.Iterate (Do_Something'Access); Another solution would be to loop using a cursor, something like: P : X_t.Cursor := X.First; while Has_Element (P) loop Do_Something (P); Next (P); -- With this loop it is possible to exit before the end -- exit when ; end loop; Both example have not been compiled, so could have some syntax error but you get the idea. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.net --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595