Explorar o código

Change GetHashCode to be equivalent to System.Drawing.Rectangle

Brandon Thetford hai 1 ano
pai
achega
feca713516
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      Terminal.Gui/Types/Rectangle.cs

+ 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>