Merge pull request #370 from amulware/improve-gethashcode
improved GetHashCode overrides of float/double Math types, closes #355
This commit is contained in:
commit
8fc672ad73
28 changed files with 184 additions and 35 deletions
|
@ -12,7 +12,7 @@ namespace OpenTK
|
|||
/// Defines a 2d box (rectangle).
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Box2
|
||||
public struct Box2 : IEquatable<Box2>
|
||||
{
|
||||
/// <summary>
|
||||
/// The left boundary of the structure.
|
||||
|
@ -190,15 +190,22 @@ namespace OpenTK
|
|||
return obj is Box2 && Equals((Box2) obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code for this Box2.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
///// <summary>
|
||||
///// Gets the hash code for this Box2.
|
||||
///// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Left.GetHashCode() ^ Right.GetHashCode() ^ Top.GetHashCode() ^ Bottom.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Left.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Right.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Top.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Bottom.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static string listSeparator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> describing the current instance.
|
||||
|
|
|
@ -12,8 +12,9 @@ namespace OpenTK
|
|||
/// Defines a 2d box (rectangle).
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Box2d
|
||||
public struct Box2d : IEquatable<Box2d>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The left boundary of the structure.
|
||||
/// </summary>
|
||||
|
@ -193,10 +194,16 @@ namespace OpenTK
|
|||
/// <summary>
|
||||
/// Gets the hash code for this Box2d.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Left.GetHashCode() ^ Right.GetHashCode() ^ Top.GetHashCode() ^ Bottom.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Left.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Right.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Top.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Bottom.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
private static string listSeparator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
|
||||
|
|
|
@ -721,7 +721,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -721,7 +721,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -679,7 +679,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -679,7 +679,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -716,7 +716,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -716,7 +716,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.Row0.GetHashCode() * 397) ^ this.Row1.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -960,7 +960,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -951,7 +951,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -690,7 +690,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -690,7 +690,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -954,7 +954,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -954,7 +954,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1715,7 +1715,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode() ^ Row3.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1665,7 +1665,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode() ^ Row3.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -739,7 +739,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode() ^ Row3.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -739,7 +739,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode() ^ Row3.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -962,7 +962,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -962,7 +962,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.Row0.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row1.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row2.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Row3.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -857,7 +857,10 @@ namespace OpenTK
|
|||
/// <returns>A hash code formed from the bitwise XOR of this objects members.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Xyz.GetHashCode() ^ W.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.xyz.GetHashCode() * 397) ^ this.w.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -854,9 +854,13 @@ namespace OpenTK
|
|||
/// Provides the hash code for this object.
|
||||
/// </summary>
|
||||
/// <returns>A hash code formed from the bitwise XOR of this objects members.</returns>
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Xyz.GetHashCode() ^ W.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.xyz.GetHashCode() * 397) ^ this.w.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1137,7 +1137,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.X.GetHashCode() * 397) ^ this.Y.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1015,7 +1015,10 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
return (this.X.GetHashCode() * 397) ^ this.Y.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1629,7 +1629,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Z.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1466,7 +1466,13 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Z.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1657,7 +1657,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Z.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.W.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1613,7 +1613,14 @@ namespace OpenTK
|
|||
/// <returns>A System.Int32 containing the unique hashcode for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = this.X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.Z.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ this.W.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue