D vs C++

bearophile bearophileHUGS at lycos.com
Sat Dec 25 09:57:33 PST 2010


Andrei:

> This behavior has been changed since a few releases ago to use 
> singly-linked lists for solving collisions.

I didn't know it, it seems I miss changes all the time :-)

This page says:
http://www.digitalmars.com/d/2.0/hash-map.html

>Classes can be used as the KeyType. For this to work, the class definition must override the following member functions of class Object:
    * hash_t toHash()
    * bool opEquals(Object)
    * int opCmp(Object)

So that page now needs to list just toHash and opEquals, there's no need of opCmp to create an unsorted linked list.

Then now D AAs are about as fragile as Python dicts, because AAs can degenerate in O(n) behaviour. Are D AAs on average faster with this change?

Bye,
bearophile


More information about the Digitalmars-d mailing list