Why Does Dscanner Warn About a Missing toHash if opEquals is Defined?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 1 03:35:29 PDT 2016


On Sunday, 31 July 2016 at 18:57:50 UTC, Jack Stouffer wrote:
> Next question: what's the fastest hashing implementation that 
> will provide the least collisions? Is there a hash 
> implementation that's perfered for AAs?

There's no hashing function that would be specifically better for 
associative arrays, it's a hashing function either way. The 
primary things that should affect what your hashing function 
looks like should be what your inputs - keys for an AA - look 
like.

djb2 is my go-to for string hashing because it's conceptually 
simple, efficient, and effective for most use cases.

http://www.cse.yorku.ca/~oz/hash.html

Every hashing function will produce collisions. As long as you 
handle them, and as long as they aren't inordinately frequent, 
you'll be fine.


More information about the Digitalmars-d-learn mailing list