Hi Berke, | Thanks for your code. I'm sorry I thought you maintained a separate | hash table. It's very interesting code and I'll give it a try. It would in fact have been more efficient to use Jean-Christophe Filliatre's implementation of Patricia trees instead of writing my own. However, it was important to me to release the code under a BSD-like license. For what it's worth, I attach a version of my code that's extracted from its context so it can be used independently. (I replaced a few of my pet functions with standard library ones, and I hope I didn't screw anything up in the process.) | - The theoretical worst-case performance of hash-based data structures | can be attained if the hash function has bad dispersal. As the code | relies on Hashtbl.hash, which does not hash deeply, this could | potentially be a proble, in particular if your keys have long "common | prefixes" that are not distinguished by the hash function. It might | work well in practice but I feel a little uncomfortable. Yes, sure. My applications are mainly in theorem proving and symbolic computation where this isn't an issue, and I can imagine it might not be suitable elsewhere. | - Also, it does not preserve the natural order for keys, and that | is particularly bad, because I often use, for instance, | float-indexed maps or sets as a substitute for heaps. When I was looking at this area last time (maybe just following the references from the paper I cited) I came across a kind of mixed heap/tree structure with distinct "horizontal" and "vertical" orderings. That might be something to consider. But once again there is a bad worst-case performance if the two orders happen to be correlated. | The paper with the inverse cubic lower bound is *very* interesting; we | don't see plausible lower bounds often in complexity theory, | especially with such large assumptions (just bounded out-degree for | the graph nodes). | | So it seems there is little hope to have a drop-in replacement for Set | or Map that is compatible with the natural order of things, a.k.a., | Pervasives.compare. Yes, I really found it striking that in a fundamental sense, you need to pay the price of noncanonicality in order to get the guaranteed O(log n) lookup. John.