Alex Rivera | Logout

Fast String Hashing Algorithm with low collision rates with 32 bit integer

Asked 2008-09-22T10:03:50.947
70

I have lots of unrelated named things that I'd like to do quick searches against. An "aardvark" is always an "aardvark" everywhere, so hashing the string and reusing the integer would work well to speed up comparisons. The entire set of names is unknown (and changes over time). What is a fast string hashing algorithm that will generate small (32 or 16) bit values and have a low collision rate?

I'd like to see an optimized implementation specific to C/C++.

Edit
Report

2 Answers

3

The Hsieh hash function is pretty good, and has some benchmarks/comparisons, as a general hash function in C. Depending on what you want (it's not completely obvious) you might want to consider something like cdb instead.

answered 2008-09-24T04:13:00.273
2

Have a look at GNU gperf.

answered 2008-09-22T10:06:20.597

Your Answer