Associative arrays in D and default comparators

Steve Horne stephenwantshornenospam100 at
Thu Sep 7 22:38:38 PDT 2006

On Thu, 07 Sep 2006 14:54:41 -0700, Sean Kelly <sean at> wrote:

>Since the AA is backed 
>by a binary tree I would expect it determine 'equality' as equivalence 
>using opCmp.

There may be special case operations on the AA where opCmp is
unnecessary and opEquals is a little faster.

But... I had got the impression that the built-in associative arrays
were done with hashtables. I think the manual says something about
foreach not enumerating the items in order.

OTOH, I didn't see any kind of 'opHash' or similar.

So - binary trees, then? Red-black, perhaps?

Or are you talking about hash collision handling?

Or have I completely got the wrong idea about something?

>Can someone 
>suggest an alternate default implementation for opCmp that solves these 

Don't know if it helps, but sometimes a consistent-but-arbitrary
ordering can give good keys. For instance, the ordering of hash values
is meaningless, but you can still use it to divide-and-conquer your

Remove 'wants' and 'nospam' from e-mail.

More information about the Digitalmars-d mailing list