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,b553d2c02a2df59f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!i40g2000cwc.googlegroups.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: limited types (Was: Records that could be arrays) Date: 27 Feb 2006 08:52:23 -0800 Organization: http://groups.google.com Message-ID: <1141059143.617291.39980@i40g2000cwc.googlegroups.com> References: <1cwl2r5h594du$.1q4kglbpb2bma.dlg@40tude.net> <10ovc4gxk6wka.gttjb2v0fbcq$.dlg@40tude.net> <13yslifejxwuq.15rip8gh2aufj.dlg@40tude.net> <44031ace$0$13779$9b4e6d93@newsread4.arcor-online.net> <1i6nwodxgp1bn.voklt7nvcl1g$.dlg@40tude.net> NNTP-Posting-Host: 66.162.65.162 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1141059164 11606 127.0.0.1 (27 Feb 2006 16:52:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Feb 2006 16:52:44 +0000 (UTC) In-Reply-To: <1i6nwodxgp1bn.voklt7nvcl1g$.dlg@40tude.net> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i40g2000cwc.googlegroups.com; posting-host=66.162.65.162; posting-account=Zl1UPAwAAADEsUSm1PMMiDjihtBlZUi_ Xref: g2news1.google.com comp.lang.ada:3187 Date: 2006-02-27T08:52:23-08:00 List-Id: Dmitry A. Kazakov wrote: > > 1. Passing as a parameter Just pass a cursor: procedure Op (C : in out Container_Type) is begin Do_Something (C.First); ... end; You know you've run out of elements when Has_Element returns False. > 2. Copying while (Has_Element (C) loop Put_Element_Somewhere (Element (C); end loop; > 3. Merging You'll need to define a relational operator over your element type, but then you can say: Merge (C1.First, C2.First); > 4. Slicing Just use a cursor pair: Do_Something (C1, C2); -- half-open range > 5. Closures and simultaneous traversal of two or more containers Do_Something (C1, C2); > 6. Relational operations on sets of containers Compare (C1, C2); If you don't understand this, go to http://charles.tigris.org and browse the Charles.Algorithms subsystem. (Things are a little different for the Ada 2005 container library, but it should give you the general idea.)