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,14be6619f79b4573 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news.illinois.net!attcg1!ip.att.net!news.binc.net!kilgallen From: Kilgallen@SpamCop.net (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: Hashing on System.Address Date: 14 Jun 2005 03:42:47 -0500 Organization: LJK Software Message-ID: References: <1118699859.296241.40700@g44g2000cwa.googlegroups.com> NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 1118738535 29100 192.135.80.34 (14 Jun 2005 08:42:15 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Tue, 14 Jun 2005 08:42:15 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:11338 Date: 2005-06-14T03:42:47-05:00 List-Id: In article , Robert A Duff writes: > "Matthew Heaney" writes: > >> Duncan Sands wrote: >> > Does anyone have an efficient portable algorithm for hashing >> > on a System.Address? >> > >> > The Ada 2005 package Ada.Containers defines Hash_Type as >> > >> > type Hash_Type is mod implementation-defined; >> > >> > This is the target type I would like for the hash. >> >> Use System.Storage_Elements.To_Integer to convert the address to an >> Integer_Address, and then convert that to type Hash_Type. > > It might be a good idea to divide that by 8, since most addresses have > zeros in the low three bits. Or it might not be, since he said portable. Looking at addresses of _instructions_ (which are the closest to that pattern) on the machine architectures on which VMS runs: VAX - No restriction, 1 bit (odd and even) just as likely to be one as the other Alpha - 4 byte boundary, 4 bit (100) just as likely to be one as the other Itanium - 8 byte boundary for VLIW instructions, but in software the last octet of the address is 0, 1 or 2 depending on which instruction in the bundle is addressed.