I am trying to generate a unique hash code for a list of integers where their order matters.
For a simple example:
{0,1,2}
and {0,2,1}
are not equal so should produce different hashcodes.
This was my attempt:
private List<int> _test1;
private List<int> _test2;
With the hash created like so:
_hash1=_hash2=0;
for (int i = 0; i < _test1.Count; i++)
_hash1 += _test1[i] * 17 + (i * 137);
for (int i = 0; i < _test2.Count; i++)
_hash2 += _test2[i] * 17 + (i * 137);
My output gives:
_hash1 = 462
_hash2 = 462
So this is clearly not working, does any one know a better solution ? I am not expert on this topic.
Thanks