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-11 14:58:05 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: 11 Jul 2003 14:58:04 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307111358.fb772@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 1057960684 9317 127.0.0.1 (11 Jul 2003 21:58:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 11 Jul 2003 21:58:04 GMT Xref: archiver1.google.com comp.lang.ada:40214 Date: 2003-07-11T21:58:04+00:00 List-Id: Craig Carey wrote in message news:... > 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: procedure Test_Hash is Map : String_Integer_Maps.Container_Type; N : Natural := 0; Last : Natural; begin if Ada.Command_Line.Argument_Count > 0 then Get (Ada.Command_Line.Argument (1), N, Last); end if; Resize (Map, N); for I in Integer range 1 .. N loop Insert (Map, To_Key (I, Base => 16), I); end loop; declare I : Iterator_Type := First (Map); J : constant Iterator_Type := Back (Map); begin while I /= J loop Put (Key (I)); Put (":"); Put (Element (I), Width => 0); New_Line; I := Succ (I); end loop; New_Line; end; Put ("map.length="); Put (Length (Map), Width => 0); New_Line; declare Count : Integer'Base := 0; begin for I in reverse Integer range 1 .. N loop if Find (Map, To_Key (I, Base => 10)) then Count := Count + 1; end if; end loop; Put ("map.count="); Put (Count, Width => 0); New_Line; end; end Test_Hash; The latest release (20030710) of Charles has better hash table support. There are also containers for storing elements whose type is limited. http://home.earthlink.net/~matthewjheaney/charles/index.html I must say, nothing beats having a predefined container library. Problems that would otherwise take hours to solve now take just minutes. -Matt