Game Development Community

Hashing

by Pat Wilson · in Technical Issues · 02/06/2001 (9:43 am) · 4 replies

I threw together a hash table class because the map in STL pissed me off. Maybe I'm just wierd, but for the most part, I find STL useless. Anyway, it's acting as a heap for a script interpreter. (A CS4 project) The key values are strings (char *) and the way I currently do the hashcode is add up the character values of that key, then mod by the table size. So far I haven't gotten any collisions, but that doesn't mean it'll never happen.

Is there a better way I could be doing this? Also, I'm going to just do chaining for collisions.

#1
02/06/2001 (1:53 pm)
Thanks Rick =)
#2
02/06/2001 (1:58 pm)
Minimal Perfect Hashing

There was also a good article on perfect hashing in the Feburary 2001 issue of Dr. Dobbs Journal. The algorithm used to implement it was very simple and produced small tables.

No problem. :)
#3
02/06/2001 (2:43 pm)
You could also check out GNU gperf and mph projects.

--Rick
#4
02/06/2001 (4:14 pm)
Ok, the only thing is, it's a template class, and if I use that method, it'll only work if I know all the keys ahead of time (if I undestand it correctly) and while this is the case this time, hash tables are handy to have around, so I figured I'd like this to be as flexable as possible.