From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Adding "()" operator to Ada 200X
Date: 3 Jun 2003 07:02:48 -0700
Date: 2003-06-03T14:02:48+00:00 [thread overview]
Message-ID: <1ec946d1.0306030602.713dfc4c@posting.google.com> (raw)
In-Reply-To: s53odv46kst9rb73a8tsuqmgft6d7ap105@4ax.com
Fionn mac Cuimhaill <invisible@hiding.from.spam> wrote in message news:<s53odv46kst9rb73a8tsuqmgft6d7ap105@4ax.com>...
> On Mon, 02 Jun 2003 16:35:01 GMT, "Frank J. Lhota"
> <NOSPAM.lhota.adarose@verizon.net> wrote:
>
> To go along with this, a way to define a slice of of an
> Array_Like_Type would be nice.
But you already can do that using iterators, e.g.
declare
I, J : Iterator_Type;
begin
Equal_Range (Multimap, Key, I, J);
--...
end;
Here the range [I, J) designates the contiguous range of items having
key value Key.
You can use Find and Generic_Find to generalize this to elements
(instead of just keys), and to other kinds of containers such as a
List.
Once you have the iterator pair that designates the range, then you
can iterate over the range:
while I /= J loop
declare
E : Element_Type renames To_Access (I).all;
begin
--...
end;
I := Succ (I);
end loop;
You could also use a passive iterator. For example, if you wanted to
copy a range of items (kind of like what a traditional slice does),
then you do something like:
declare
Another_List : List_Subtype;
procedure Process (I : Iterator_Type) is
E : constant Element_Type := Element (I);
--or E : Element_Type renames To_Access (I).all;
begin
Push_Back (Another_List, E);
end;
procedure Iterate is
new Generic_Select_Elements (Process);
begin
Iterate (I, J);
--now Another_List has a copy of the elements
--from List in the range [I, J)
end;
next prev parent reply other threads:[~2003-06-03 14:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-02 16:35 Adding "()" operator to Ada 200X Frank J. Lhota
2003-06-02 23:42 ` Matthew Heaney
2003-06-03 14:59 ` Frank J. Lhota
2003-06-03 15:09 ` Frank J. Lhota
2003-06-03 16:04 ` Martin Krischik
2003-06-04 17:28 ` Matthew Heaney
2003-06-04 18:21 ` Frank J. Lhota
2003-06-05 1:15 ` Robert I. Eachus
2003-06-05 14:59 ` Frank J. Lhota
2003-06-05 17:25 ` Matthew Heaney
2003-06-03 20:24 ` Randy Brukardt
2003-06-03 19:52 ` Francisco Javier Loma Daza
2003-06-03 2:56 ` Fionn mac Cuimhaill
2003-06-03 14:02 ` Matthew Heaney [this message]
2003-06-03 16:23 ` Mário Amado Alves
2003-06-05 19:02 ` Dmitry A. Kazakov
2003-06-06 10:56 ` Mário Amado Alves
2003-06-06 16:55 ` Chad R. Meiners
2003-06-06 19:01 ` Frank J. Lhota
2003-06-09 14:15 ` Matthew Heaney
2003-06-07 8:36 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox