This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: hash?
- To: hanwen at cs dot uu dot nl
- Subject: Re: hash?
- From: Greg Harvey <Greg dot Harvey at thezone dot net>
- Date: 24 Dec 1999 12:31:44 -0330
- Cc: guile at sourceware dot cygnus dot com
- References: <14435.21234.279317.759162@dokkum.cs.uu.nl>
Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:
> Am I missing something here? Shouldn't this give distinct results?
>
> guile> (hash "feta11" 1000000)
> 909281
> guile> (hash "feta13" 1000000)
> 909281
> guile> (hash "feta16" 1000000)
> 909281
>
It doesn't necessarily have to (that being the nature of hashes and
all); the code for strhash when strings are > 5 characters long only
uses five characters of the string to determine the hash; in this
case, the particular selection of hash size, strings, and string
lengths have given us the dreaded `worst case scenario'.
Looking at the code I'm curious about the selection of initial hash as
264 % table size; I'd think it'd be better to make the generated hash
totally dependant on the value being hashed, rather than a fixed start
value for each hash for a particular size table (264 might not be the
best value to go there, either, but it's been a while since I've
looked deeply at hashes, so I might just be being prime-centric).
--
Gregh: primes are cool, though :)