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!news2.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: Matthew Heaney@MHEANEYIBMT43 Newsgroups: comp.lang.ada Subject: Re: Ada Hash References: <1177429033.247571.9090@s33g2000prh.googlegroups.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 29 Apr 2007 18:33:08 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1177871588 24.149.57.125 (Sun, 29 Apr 2007 11:33:08 PDT) NNTP-Posting-Date: Sun, 29 Apr 2007 11:33:08 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:15400 Date: 2007-04-29T18:33:08+00:00 List-Id: markp writes: > 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? You just need an identity function, as Randy pointed out: function Hash (N : Natural) return Hash_Type is begin return Hash_Type (N); end; If your integer subtype has negative values, then you could do something like: function Hash is new Unchecked_Conversion (Integer, Hash_Type); You could also use one of the ordered forms directly. Integer subtypes have a less-than relational operator by default, so there's nothing else you would need to do.