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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,eec376a334ad59ed X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-10 16:36:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.vmunix.org!peernews!peer.cwci.net!news5-gui.server.ntli.net!ntli.net!news2-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: Subject: Re: hashing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 Message-ID: <604t8.3744$tZ1.983158@news2-win.server.ntlworld.com> Date: Thu, 11 Apr 2002 00:36:20 +0100 NNTP-Posting-Host: 62.252.136.12 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 1018481794 62.252.136.12 (Thu, 11 Apr 2002 00:36:34 BST) NNTP-Posting-Date: Thu, 11 Apr 2002 00:36:34 BST Organization: ntlworld News Service Xref: archiver1.google.com comp.lang.ada:22337 Date: 2002-04-11T00:36:20+01:00 List-Id: "Steven Deller" wrote in message news:mailman.1018477621.31315.comp.lang.ada@ada.eu.org... > > Subject: hashing > > Hi, > > > > Does anyone have a good hash function for strings (length is > > arbitary, number of buckets is determined when package is I'll maybe look into that (if it doesn't involve reverse engineering C). I found one that may suffice for the purposes of the exercise, it's nothing fancy but it should work. Sum all ascii vals of chars in string, then take modulo bucket size. > Other than that, I'd try one of the numerous ISO-defined hash functions, > such as CRC-32, etc. ISO define hash functions? > I did a web search on "hash function algorithms" and came up with > NUMEROUS interesting sites. oops wrong search string, "hash function strings". Got loads of stuff in code, but code is not as useful. Algorithm/function descriptions (mathematics included) are better than code IMO, since they express algorithms functions in a programming language independant manner. When we were learning about bstrees they gave us Ada code which made no sense at the time due to poor descriptions of the algorithms and considerations involved. However when we learned how to do bstrees in Haskell, just before easter break it made perfect sense since the lecturer took the time to describe the algorithms. The code was secondary to the algorithm. [snip] > > p.p.s. should performance/complexity information be included? > > I seem to recall a conversation on this a while back, but > > can't remember if ppl thought it was a good idea. > > Complexity information always raises its head at some point. Best to > include it. it does makes sense to include it and it'll definitely go in the gmgpl version... But does complexity information come under the header of an implementation detail? i don't think it does but if it does and I include it in the spec, my tutor might disagree and I'll get penalised. This is one of my grumps about uni, not knowing what they want with things. In first year, you'd get penalised for *not* putting pointless comments in. Ignore that, I'm probably worrying about nothing!!! Thanks, Chris