2
0
Эх сурвалжийг харах

Change GetHashCode to be equivalent to System.Drawing.Rectangle

Brandon Thetford 1 жил өмнө
parent
commit
feca713516

+ 4 - 1
Terminal.Gui/Types/Rectangle.cs

@@ -261,7 +261,10 @@ public struct Rectangle
 
     /// <summary>GetHashCode Method</summary>
     /// <remarks>Calculates a hashing value.</remarks>
-    public override int GetHashCode () { return (Height + Width) ^ (X + Y); }
+    public override int GetHashCode () { return X ^
+                                                ((Y << 13) | (Y >>> 19)) ^
+                                                ((Width << 26) | (Width >>>  6)) ^
+                                                ((Height <<  7) | (Height >>> 25)); }
 
     /// <summary>IntersectsWith Method</summary>
     /// <remarks>Checks if a Rectangle intersects with this one.</remarks>