Original Post
I was looking for information on hash tables, and found quite a lot in Wikipedia and some books... but, I'm not very confident on the solutions everyone propose. I implemented a solution that works fine, but I don't want to keep the doubt, because I could be missing something that might make my algorithm faster. First, I'll explain that I need a table that is indexed with string keys... indeed I made a base class that accepts any type of key using generic pointers, but the main usage of inherited tables is with string keys. Also, the tables are nodes of a multinode tree. My doubt is about the hashing algorithm. As I understood it, the idea is representing the string key with a data type that is smaller and faster to index, like an integer. But, I don't think it will always work perfectly. There must be some cases where strings will share the same hash code, and I don't want to allow this to happen. On the other hand, having a static array for all the possible hash codes seems to be a big waste of memory. In example, an array of 65536 elements (let's say pointers) would mean 65536 * (4 bytes) is too much, and returning to the other doubt, I don't think 16 bits is enough to encode every key... but what's enough? 32 bits, 64 bits??? The only reliable way I can think of is a data type long enought to store a compressed version of the string. Now what I did is based on the QuickSort algorithm. I just sort every inserted key halving the list each time to find the right place. And to extract the information I do the same. Since the list is always sorted it isn't too slow to find something... althought there is a delay that I would like to reduce as possible. Any advice on this will be greatly appreciated. Byt the way, HAPPY NEW YEAR! :D