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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73f15dbe4ec16d06 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-03 07:02:48 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Adding "()" operator to Ada 200X Date: 3 Jun 2003 07:02:48 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0306030602.713dfc4c@posting.google.com> References: NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1054648968 11450 127.0.0.1 (3 Jun 2003 14:02:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 3 Jun 2003 14:02:48 GMT Xref: archiver1.google.com comp.lang.ada:38473 Date: 2003-06-03T14:02:48+00:00 List-Id: Fionn mac Cuimhaill wrote in message news:... > On Mon, 02 Jun 2003 16:35:01 GMT, "Frank J. Lhota" > 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;