Hi,
it does not look like a good hash (in term of probability of collisions)
and would deserve a revision.
But what problem did you detect wrt equality?

The implication is this way:
   self assert: (a = b) ==> (a hash = b hash)

Since the element hash are bitXor'ed, the resulting hash will be
independent of ordering of elements.
It will thus work for unordered collections (like Set in which ordering
depends on container size).
(and badly for others if they omit to refine hash).

Or is it because Collection of different species could be equal?

Nicolas

2018-06-20 23:15 GMT+02:00 <[email protected]>:

> Hi,
>
> I was watching to the Collection>>#hash implementation and I found
> something strange:
> self size <= 10 ifTrue:
>                                 [self do: [:elem | hash := hash bitXor:
> elem hash]].
>
> Can someone know why the contents are only considered for the hash if the
> collection size is below 10? Is that a bug or a feature?
>
> Moreover, it is in contradiction with the end of the comment:
> -- two equal objects have equal hash values
>
> TIA,
>
> Cheers,
> Vincent
>
>

Reply via email to