This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: hash?


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 :)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]