AA with complex keytype?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Feb 9 13:21:58 PST 2007
Manfred Nowak wrote:
>> So if x != y, then both x < y and y < x? That wouldn't make sense
>> at all.
>
> Enough sense for an AA: all colliding elements are put into a linear
> list and searched in sequence on retrieval. Without a good toHash this
> would natrally lead to a bad runtime behaviour.
If they'd be put into a linear list you wouldn't even *need* opCmp, so
no opCmp would be "enough sence" as well ;).
But the fact is they are put into a binary tree to keep acceptable
behavior (i.e. O(log N) instead of O(N)) when the hash function sucks.
Since hash functions can be user-defined, and not all users are experts
at hashing, you need to consider that use case.
More information about the Digitalmars-d
mailing list