Why can't or shouldn't I just hash the address of an object? And how.

Neia Neutuladh neia at ikeran.org
Sun Dec 30 05:54:05 UTC 2018


On Sun, 30 Dec 2018 05:36:41 +0000, Enjoys Math wrote:
> Is it:
> 
> typeof(T).getHash(&o)?

This gets the hashcode for the object by calling toHash() on it.

> Or does that do something other than just get the address?

It XORs the address with a bitwise rotation of the address. This reduces 
collisions since objects are allocated aligned.

As for your larger problem, I'd strongly tend toward using a database to 
hold application state instead of keeping it in memory.


More information about the Digitalmars-d-learn mailing list