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,a3736685ef876ab2 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!tudelft.nl!txtfeed1.tudelft.nl!feeder1.cambrium.nl!feed.tweaknews.nl!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: OO Style with Ada Containers References: <1195082906.420079.195000@d55g2000hsg.googlegroups.com> <1195084214.480299.13970@t8g2000prg.googlegroups.com> <1195084752.840598.174460@v65g2000hsc.googlegroups.com> <1195086265.070953.93180@d55g2000hsg.googlegroups.com> <87oddv3l55.fsf@ludovic-brenta.org> <4e65cf83-b296-497f-848e-59d543c19a46@v4g2000hsf.googlegroups.com> <87abpf3fno.fsf@ludovic-brenta.org> <63fc95f4-1245-46e3-8c4b-7eabdd57fd91@c29g2000hsa.googlegroups.com> Date: Thu, 15 Nov 2007 21:18:33 +0100 Message-ID: <87y7cz1cva.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:ezI8kuHNTo29apnt3jxFAVSULGE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tele2 X-Trace: DXC=9mU7fG[U53PoPfY8k93I=V6`Y6aWje^YZoG?b?>^RXPZ1B4<]HH1:nSnZE^Amh3KDR^e28Id_fHXW Xref: g2news1.google.com comp.lang.ada:18426 Date: 2007-11-15T21:18:33+01:00 List-Id: braver writes: > On Nov 15, 2:35 pm, Ludovic Brenta wrote: >> Position := Counters.Find (Current_Word); > > It turned out this should be > > -- Count can be anything below due to our definition of Equivalent: > Position := Counters.Find ((Word => Current_Word, Count => 0)); > > -- which adds to the cumbersomeness of Hashed_Sets vs. Ordered_Maps. > So what are the advantages? I think Find is much more efficient in a Hashed_Set than in an Ordered_Map because comparing hash values is more efficient than comparing Unbounded_Strings. And in the algorithm, we call Find for each word in the input. This applies to Insert, too, and we call Insert for every new word in the input. How about trying both solutions and benchmarking them? -- Ludovic Brenta.