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,76e8d825615718a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!feeder.erje.net!eternal-september.org!news.eternal-september.org!aioe.org!not-for-mail From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Ada.Containers Hash function for a set of small integers Date: Thu, 22 Apr 2010 21:39:46 -0400 Organization: The Wasteland Message-ID: References: <50701baa-7c05-450c-a42d-c699516ddc00@t14g2000prm.googlegroups.com> NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news2.google.com comp.lang.ada:11116 Date: 2010-04-22T21:39:46-04:00 List-Id: In article <50701baa-7c05-450c-a42d-c699516ddc00@t14g2000prm.googlegroups.com>, Michael R wrote: > Hi Folks, > > I'd like to use the generic Hashed_Maps container to store mappings > from a set of small integers (three) to Wide_Strings > (Indefinite_Hashed_Maps): > > (1, 10, 4) => "ABC", > (10, 3, 5) => "XYZ", > > Does anyone have recommendations on how best to implement the Hash > function for keys like this? I'd try something simple like shift and add, but it might depend on the definition of "small". Whatever you decide, here's some code I used to examine the distribution of collisions in a map keyed by "/usr/share/dict/words": $ ./collisions 0: 218586 (55.59%) 1: 126250 (32.10%) 2: 38432 (9.77%) 3: 8362 (2.13%) 4: 1354 (0.34%) 5: 229 (0.06%) 6: 24 (0.01%) 7: 4 (0.00%) 8: 1 (0.00%) -- John B. Matthews trashgod at gmail dot com