Hello,

Thanks for this complete answer. I will take a look to your code.
Additionally, Ali gave me a really interesting link about hashing, good practices, what is efficient, etc. If you didn't read it, it might interest you. Here it is:

http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx

Le 07/11/2012 13:10, Dan a écrit :
On Wednesday, 7 November 2012 at 06:38:32 UTC, Raphaël Jakse wrote:
[...]
Ali agreed that concatenating strings each time would indeed be
inefficient. He thought we might cache the value (third solution) :

Interesting about caching the hashcode and on large classes could save
you. But isn't the signature shown const? Would that compile?

Indeed, I didn't tested this code, I just wanted to explicit what I wanted to say. Thank you for the notice.

Also, what
if you change the strings - you get the wrong hash? I suppose you could
limit writes to properties and null the hashcode on any write.

Yes, good question and good idea, I think I would do it this way. I didn't think about it.


Questions are :
 - what is the most efficient solution, and in which case ?

No string concatenation is good. I think a single pass on all important
data (in most cases is all the data) is the goal.

I'm not sure I understood well. You wanted to say that string contatenations are good, right ?

I was thinking about a hash function that would take several arguments and hash them together. That would let take in account more than one string in the hash while avoiding concatenation.

[...]

Thanks
Dan


Reply via email to