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,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-14 11:46:42 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: 14 Jul 2003 11:46:41 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307140717.504f5238@posting.google.com> References: <1ec946d1.0307111358.fb772@posting.google.com> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1058208401 16665 127.0.0.1 (14 Jul 2003 18:46:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 14 Jul 2003 18:46:41 GMT Xref: archiver1.google.com comp.lang.ada:40266 Date: 2003-07-14T18:46:41+00:00 List-Id: mheaney@on2.com (Matthew Heaney) wrote in message news:<1ec946d1.0307111358.fb772@posting.google.com>... > > The Ada 95 entries have appeared that the new > > "Computer Language Shootout" website: > > > > http://dada.perl.it/shootout/gnat.html > > I just cobbled together the "hash table (associative array)" example > using the hashed set in Charles. Here it is: Here's the "hash2" shootout problem, coded using the hashed map in Charles: procedure Test_Hash is M1, M2 : String_Integer_Maps.Container_Type; N : Positive; type Element_Access is access all String_Integer_Maps.Element_Subtype; for Element_Access'Storage_Size use 0; function To_Access is new Generic_Element (Element_Access); begin if Ada.Command_Line.Argument_Count = 0 then N := 1; else declare Last : Natural; begin Get (Ada.Command_Line.Argument (1), N, Last); end; end if; Resize (M1, 10000); for I in Integer range 0 .. 9999 loop Insert (M1, "foo_" & To_Key (I, Base => 10), I); end loop; Put ("m1[foo_1]="); Put (Element (Find (M1, "foo_1")), Width => 0); New_Line; Put ("m1[foo_9999]="); Put (Element (Find (M1, "foo_9999")), Width => 0); New_Line; Resize (M2, Length (M1)); for I in Integer range 1 .. N loop declare I1 : Iterator_Type := First (M1); J1 : constant Iterator_Type := Back (M1); I2 : Iterator_Type; B : Boolean; begin while I1 /= J1 loop Insert (M2, Key (I1), 0, I2, B); declare E : Element_Subtype renames To_Access (I2).all; begin E := E + Element (I1); end; I1 := Succ (I1); end loop; end; end loop; Put ("m2[foo_1]="); Put (Element (Find (M2, "foo_1")), Width => 0); New_Line; Put ("m2[foo_9999]="); Put (Element (Find (M2, "foo_9999")), Width => 0); New_Line; end Test_Hash; I don't imagine that any of the shootout examples would be difficult to implement in Ada95, or any less efficient. http://home.earthlink.net/~matthewjheaney/charles/index.html -Matt