From: Pascal Obry <pascal@obry.net>
Subject: Re: How to loop (elegant) throug a vector ?
Date: Fri, 20 Jun 2008 16:49:44 +0200
Date: 2008-06-20T16:49:44+02:00 [thread overview]
Message-ID: <485bc388$0$891$ba4acef3@news.orange.fr> (raw)
In-Reply-To: <aMednZL3l638M8bV4p2dnAA@telenor.com>
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 <some_condition>;
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
next prev parent reply other threads:[~2008-06-20 14:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-20 13:19 How to loop (elegant) throug a vector ? Reinert Korsnes
2008-06-20 14:49 ` Pascal Obry [this message]
2008-06-20 17:12 ` Returning ranges from a function (was: How to loop (elegant) throug a vector ?) Stefan Bellon
2008-06-22 14:01 ` Maciej Sobczak
2008-06-22 18:47 ` Stefan Bellon
2008-06-22 21:06 ` Maciej Sobczak
2008-06-23 9:47 ` Stefan Bellon
2008-06-23 12:06 ` Maciej Sobczak
2008-06-23 12:28 ` christoph.grein
2008-06-20 19:21 ` How to loop (elegant) throug a vector ? Jeffrey R. Carter
2008-06-20 19:48 ` Reinert Korsnes
2008-06-20 23:25 ` Jeffrey R. Carter
2008-06-23 17:14 ` Matthew Heaney
2008-06-23 17:11 ` Matthew Heaney
2008-06-23 17:08 ` 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