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,a8c6c308ebb6a246 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: hashed_maps Date: 13 Oct 2005 17:27:04 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1129046337.130908.137510@g47g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1129238824 28643 192.74.137.71 (13 Oct 2005 21:27:04 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 13 Oct 2005 21:27:04 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5617 Date: 2005-10-13T17:27:04-04:00 List-Id: Bj�rn Persson writes: > Lucretia wrote: > > What's the best way to create a hashed_map which maps from > > System.Address :-> an access type? > > In other words, how do you write a good hash function that turns memory > addresses into evenly distributed hash values? I seem to recall that > just this question was discussed here in comp.lang.ada some time ago > (several months, maybe a year or more ago). You could search in Google > groups. (That is, if you really expect to have so many windows that you > need to have a hash table and not a tree.) Addresses usually have the low 2 or 3 bits equal to zero, because of alignment concerns. So use Address_To_Integer and shift right 3 bits. Then mod by the size of the hash table, or take some high-order bits and add them into the low-order bits. - Bob