by fmap · 15y ago · 0 comments
At the same time you will not need rehashing once the table "fills up" and since you use don't discard bits from the hash function the expected number of collisions after inserting n elements with a 32 bit hash is n / 2^32 - or 0 for reasonable values of n.
Additionally you can use clustering (e.g. build a crit-nibble tree, with 16 pointers per node - one 64 byte cache line) to reduce the number of cache misses. This can backfire spectacularly unless the data is essentially random, so the hashing step remains important.
It may not be a silver bullet, but there are some interesting trade-offs.
If the data structure is unordered, I don't see any reason why it should be better than a normal hash table.
For instance, you don't have to do a rehashing step, which is important for real time applications. Memory usage is also very deterministic at 2*(n-1) words in an n element table (with 2 words per node).
If none of this matters to you and you merely want a map with fast lookups then a simple hash table is probably a better choice.
http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.57.59...