Happy Happy Joy Joy (was: On to Hydro)
Jonathan S. Shapiro
Wed, 23 Aug 2000 13:20:31 -0400
> My RedBlackTree does use a configurable comparison predicate (where
> this whole thread started from), but my Hashtable does not support a
> separate hashing function. Could you explain why you would want one?
One explanation is that I may know something about the distribution of hash
values or the number of entries I plan to insert that leads me to want to
specify both a hash function and a number of buckets.
Another is that I may wish to hash based on the value of the object (using
some suitable universaly deterministic function) rather than on it's
identity -- this is currently done in DCMS, in fact.
For identity-based hash tables, the values are opaque and it is therefore
best to let the implementation choose the hash function. Also, re-balancing
hash strategies are now fairly routine for such things. The point is that in
this case there isn't anything helpful that the user can do by supplying a
function, and the implementation is in a better position to choose a good
For content-based hashes, however, the hash function should certainly be