Exemplo n.º 1
0
		public void TestGetHashCode()
		{
			{
				Vector2 a = new Vector2(10, 11);
				Vector2 b = new Vector2(10, 11);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				Vector3 a = new Vector3(10, 11, 12);
				Vector3 b = new Vector3(10, 11, 12);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				Vector4 a = new Vector4(10, 11, 12, 13);
				Vector4 b = new Vector4(10, 11, 12, 13);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				Quaternion a = new Quaternion(10, 11, 12, 13);
				Quaternion b = new Quaternion(10, 11, 12, 13);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				Matrix4X4 a = Matrix4X4.CreateRotationX(3);
				Matrix4X4 b = Matrix4X4.CreateRotationX(3);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
		}
Exemplo n.º 2
0
 public void Vector3GetHashCodeTest()
 {
     Vector3 v1 = new Vector3(2.0f, 3.0f, 3.3f);
     Vector3 v2 = new Vector3(4.5f, 6.5f, 7.5f);
     Vector3 v3 = new Vector3(2.0f, 3.0f, 3.3f);
     Vector3 v5 = new Vector3(3.0f, 2.0f, 3.3f);
     Assert.True(v1.GetHashCode() == v1.GetHashCode());
     Assert.False(v1.GetHashCode() == v5.GetHashCode());
     Assert.True(v1.GetHashCode() == v3.GetHashCode());
     Vector3 v4 = new Vector3(0.0f, 0.0f, 0.0f);
     Vector3 v6 = new Vector3(1.0f, 0.0f, 0.0f);
     Vector3 v7 = new Vector3(0.0f, 1.0f, 0.0f);
     Vector3 v8 = new Vector3(1.0f, 1.0f, 1.0f);
     Vector3 v9 = new Vector3(1.0f, 1.0f, 0.0f);
     Assert.False(v4.GetHashCode() == v6.GetHashCode());
     Assert.False(v4.GetHashCode() == v7.GetHashCode());
     Assert.False(v4.GetHashCode() == v8.GetHashCode());
     Assert.False(v7.GetHashCode() == v6.GetHashCode());
     Assert.False(v8.GetHashCode() == v6.GetHashCode());
     Assert.True(v8.GetHashCode() == v7.GetHashCode());
     Assert.False(v8.GetHashCode() == v9.GetHashCode());
     Assert.False(v7.GetHashCode() == v9.GetHashCode());
 }
Exemplo n.º 3
0
 public void Vector3GetHashCodeTest()
 {
     Vector3 v1 = new Vector3(2.0f, 3.0f, 3.3f);
     Vector3 v2 = new Vector3(2.0f, 3.0f, 3.3f);
     Vector3 v3 = new Vector3(2.0f, 3.0f, 3.3f);
     Vector3 v5 = new Vector3(3.0f, 2.0f, 3.3f);
     Assert.Equal(v1.GetHashCode(), v1.GetHashCode());
     Assert.Equal(v1.GetHashCode(), v2.GetHashCode());
     Assert.NotEqual(v1.GetHashCode(), v5.GetHashCode());
     Assert.Equal(v1.GetHashCode(), v3.GetHashCode());
     Vector3 v4 = new Vector3(0.0f, 0.0f, 0.0f);
     Vector3 v6 = new Vector3(1.0f, 0.0f, 0.0f);
     Vector3 v7 = new Vector3(0.0f, 1.0f, 0.0f);
     Vector3 v8 = new Vector3(1.0f, 1.0f, 1.0f);
     Vector3 v9 = new Vector3(1.0f, 1.0f, 0.0f);
     Assert.NotEqual(v4.GetHashCode(), v6.GetHashCode());
     Assert.NotEqual(v4.GetHashCode(), v7.GetHashCode());
     Assert.NotEqual(v4.GetHashCode(), v8.GetHashCode());
     Assert.NotEqual(v7.GetHashCode(), v6.GetHashCode());
     Assert.NotEqual(v8.GetHashCode(), v6.GetHashCode());
     Assert.NotEqual(v8.GetHashCode(), v9.GetHashCode());
     Assert.NotEqual(v7.GetHashCode(), v9.GetHashCode());
 }
 private int CalculatePositionId(Vector3 position)
 {
     return (int)position.GetHashCode() * timeSeed;
 }
Exemplo n.º 5
0
		public static void HashCode (int times)
		{
			var value = new Vector3 (0.1f, -2f, -0.2f);
			int result;
			
			for (int i = 0; i < times; i++) {
				result = value.GetHashCode ();
			}
		}
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     return(center.GetHashCode() ^ radius.GetHashCode() << 2);
 }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(pos.GetHashCode() ^ rot.GetHashCode());
 }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     return(_vector.GetHashCode());
 }
Exemplo n.º 9
0
 public override int GetHashCode() => value.GetHashCode();
Exemplo n.º 10
0
 public override int GetHashCode()
 {
     return(Position.GetHashCode() | Normal.GetHashCode() | Color.GetHashCode());
 }
Exemplo n.º 11
0
Arquivo: Ray.cs Projeto: vvvv/stride
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(Position.GetHashCode() + Direction.GetHashCode());
 }
Exemplo n.º 12
0
 /// <summary>Gets the hash code for this object.</summary>
 public override int GetHashCode()
 {
     return(Normal.GetHashCode() + D.GetHashCode());
 }
Exemplo n.º 13
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(Start.GetHashCode() + End.GetHashCode());
 }
Exemplo n.º 14
0
 public override int GetHashCode()
 {
     return(position.GetHashCode() ^ rotation.GetHashCode());
 }
Exemplo n.º 15
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(Center.GetHashCode() + Radius.GetHashCode());
 }
Exemplo n.º 16
0
 public void A_hashcode_should_be_returned()
 {
     const int expected = -1386971136;
     var testVector = new Vector3(42, 66, 23);
     var actual = testVector.GetHashCode();
     Assert.AreEqual(actual, expected);
 }
Exemplo n.º 17
0
 public override int GetHashCode()
 {
     return(origin.GetHashCode() ^ direction.GetHashCode() << 2);
 }