User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:csharp:equality [2020/06/30]
notes:csharp:equality [2020/06/30] (current)
Line 154: Line 154:
 dictionary.Remove(c1);​ dictionary.Remove(c1);​
 dictionary.Add(c2,​ empl); dictionary.Add(c2,​ empl);
 </​code>​ </​code>​
 +A commonly used algorithm to generate the **uniform distribution** of keys is to XOR all the return values from ''​%%GetHashCode%%''​ on all immutable fields in a type. Keep in mind that if the fields'​ values are somehow related, this algorithm will cluster hash codes. As a result, your container will have few buckets each with many items.
notes/csharp/equality.txt ยท Last modified: 2020/06/30 by leszek