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: a07f3367d7,918406c619dd104d,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!nospam From: "John B. Matthews" Newsgroups: comp.lang.java.programmer,comp.lang.ada Subject: Re: find words that contains some specific letters Date: Sat, 06 Jun 2009 12:13:19 -0400 Organization: The Wasteland Message-ID: References: <78i1lbF1m69gkU1@mid.individual.net> <78i2ajF1m4nglU1@mid.individual.net> <78i4i2F1magkfU1@mid.individual.net> <3f1d007f-bcae-42b4-afb0-215b18f51b9c@n21g2000vba.googlegroups.com> <78ib19F1mfh7qU1@mid.individual.net> <3b519936-3db9-4dad-85ba-371fa4b29c8f@z5g2000vba.googlegroups.com> <78quiaF1n95fsU1@mid.individual.net> <78rpbkF1mqrc7U1@mid.individual.net> NNTP-Posting-Host: ib4TTflHUauJidfWP/+Rjw.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.7.9 Cancel-Lock: sha1:h3n2CP7+rBQHlLXaAOv2yeUeWB4= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news2.google.com comp.lang.java.programmer:42905 comp.lang.ada:6334 Date: 2009-06-06T12:13:19-04:00 List-Id: In article <78rpbkF1mqrc7U1@mid.individual.net>, "Giovanni Azua" wrote: > "Patricia Shanahan" wrote in message > > A perfect hash function is one that guarantees distinct hash codes > > for a specific set of keys. There are algorithms for constructing > > one, given a set of keys. > > For example the Character class. I think all of the primitive wrappers (except Double) have trivially perfect integer hashes, as they wrap distinct values. Patricia was perhaps referring to algorithms of the kind discussed here: The jumble algorithm relies on a hashed map for efficiency, but a perfect hash is not essential. I recently implemented the algorithm in both Java and Ada using library routines: I was intrigued to compare the two languages' library implementations of a general purpose string hash. Using a multiplicative function with an initial value of zero, both offer excellent performance. Java uses a multiplier of 31 on a signed 32-bit integer; Ada uses a multiplier of eight on an unsigned (modular) value whose size is implementation defined (e.g. mod 2**32): [Cross-posted to comp.lang.java.programmer and comp.lang.ada; Followup-To header not set.] -- John B. Matthews trashgod at gmail dot com