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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,76e8d825615718a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!not-for-mail From: =?iso-8859-15?Q?Yannick_Duch=EAne_=28Hibou57=29?= Newsgroups: comp.lang.ada Subject: Re: Ada.Containers Hash function for a set of small integers Date: Wed, 05 May 2010 06:29:02 +0200 Organization: Ada At Home Message-ID: References: <50701baa-7c05-450c-a42d-c699516ddc00@t14g2000prm.googlegroups.com> NNTP-Posting-Host: RFJcNObQ4K0QDDxOKl/MTg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news2.google.com comp.lang.ada:11315 Date: 2010-05-05T06:29:02+02:00 List-Id: Le Fri, 23 Apr 2010 23:39:52 +0200, Simon Wright a = = =E9crit: > I don't know about 'best', but in ColdFrame > (http://coldframe.sourceforge.net/coldframe/) I would generate this ha= sh > for use with Booch Maps, where the key components of Instance are > {A:Integer, B:Integer, C:Integer}: > > function Instance_Hash (I : Instance) return Natural is > type M is mod 2**31; > Result : M :=3D 0; > begin > Result :=3D Result xor M (I.A mod 2**31); > Result :=3D Result * 10019; > Result :=3D Result xor M (I.B mod 2**31); > Result :=3D Result * 10019; > Result :=3D Result xor M (I.C mod 2**31); > Result :=3D Result * 10019; > return Natural (Result); > end Instance_Hash; > > I believe the 10019 came from Knuth, but can't see a reference. Unlucky, I was to ask you how this 10_019 was computed. At least, this = magic number is not a prime number, the nearest is 1009. If this can help, may be some goodies there : http://www.isthe.com/chongo/tech/comp/fnv/ http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx -- = No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just= = not lucky