associativeArray.toHash()
Michiel
nomail at please.com
Wed Feb 21 18:05:50 PST 2007
Michiel wrote:
> I'm now implementing the toHash() function of my new Set class. But I'm
> not sure how to extract hash-information from an associative array of
> which the key-type can be anything. The values are irrelevant. So you
> might see the problem as extracting hash-information from its .keys array.
>
> I'm sure the hash-information of its key-type can be retrieved, since
> that's how the associative array works in the first place. How do I
> retrieve it manually?
I think I found a way in Phobos, but it might not be the most elegant
one. I used std.boxer to pack each element of the array into a box. Then
I call the Box.toHash() function on each and use the sum to calculate
the sets hash.
Is there a better way?
It does seem to work. I can now have sets of sets of sets of whatever,
and it still works as expected.
I'll continue to tweak the class a bit and then I'll publish it here.
--
Michiel
More information about the Digitalmars-d
mailing list