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,3ccb3e085f1dd380 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada Hash Date: Tue, 24 Apr 2007 13:12:50 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1177429033.247571.9090@s33g2000prh.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1177438257 4585 69.95.181.76 (24 Apr 2007 18:10:57 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 24 Apr 2007 18:10:57 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15263 Date: 2007-04-24T13:12:50-05:00 List-Id: "markp" wrote in message news:1177429033.247571.9090@s33g2000prh.googlegroups.com... > I need to use a hash table to store data using an integer as the key. > I would like to use Ada.Containers.Hashed_Maps. Is there a default > hash function for an integer that I can supply to the instantiation > and could somebody provide a quick sample piece of code to do this? There isn't a default function for this; but generally you don't need one - the identity function would work fine unless your integers are distributed unusually. In any case, writing hash functions is an art; I generally test as many as a dozen possibilities on sample data sets to see which one(s) work best. What works best depends totally on your data; there is no such thing as a good predefined hash function. (OTOH, if you don't have much data, anything might be good enough -- but if that is true, why use the hashed container form at all? The Ordered forms are easier to use and cost about the same on small data sets.) Randy.