<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Hashing maps using xor?  Oh dear.  That's really not a good method.</div><div class="gmail_default" style="font-family:monospace,monospace">I found a much better way to hash sets and maps, but couldn't find</div><div class="gmail_default" style="font-family:monospace,monospace">a journal that thought it was in their scope.  Actually, there are</div><div class="gmail_default" style="font-family:monospace,monospace">several good ways.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Now you are locked into an inferior one.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 29 Aug 2019 at 03:19, Lukas Larsson <<a href="mailto:lukas@erlang.org">lukas@erlang.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 28, 2019 at 8:45 AM Frans Schneider <<a href="mailto:fchschneider@gmail.com" target="_blank">fchschneider@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list,<br>
<br>
According to the docs, the erlang:phash2/2 will return the same result <br>
regardless of machine architecture and ERTS version. Does this imply <br>
that this is still true in case the implementation of a basic type, lets <br>
say a list or map (#{}), will change in the future? Can I assume that <br>
calculating a hash for a list will have the same result now and in the <br>
future?<br></blockquote><div><br></div><div>Yes. The way hashing of maps works is that it hashes each k/v pair and then takes the xor of each of those hashes. Since a series of xor's can be applied in any order without changing the result, the hash value will always be the same.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks<br>
<br>
<br>
Frans<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>