本文整理汇总了C#中Vector.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.GetHashCode方法的具体用法?C# Vector.GetHashCode怎么用?C# Vector.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.GetHashCode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: equal_vectors_have_equal_hashcodes
public void equal_vectors_have_equal_hashcodes()
{
var v1 = new Vector<int>(new int[] { 1, 2, 3 }, Orientation.Row
, AdditiveMonoid.IntAdditionMonoid, MultiplicativeMonoid.IntMultiplicationMonoid);
var v2 = new Vector<int>(new int[] { 1, 2, 3 }, Orientation.Row
, AdditiveMonoid.IntAdditionMonoid, MultiplicativeMonoid.IntMultiplicationMonoid);
Assert.IsTrue(v1 == v2);
Assert.That(v1.GetHashCode(), Is.EqualTo(v2.GetHashCode()));
}
示例2: TestEquals
public void TestEquals()
{
Vector vector1 = new Vector(1.0, 2.0, 3.0);
Vector vector2 = new Vector(1.0, 2.0, 3.0);
Assert.That(vector1, Is.Not.SameAs(vector2));
Assert.That(vector1, Is.EqualTo(vector2));
Assert.False(vector1.Equals(null));
Assert.That(vector1.GetHashCode(), Is.EqualTo(vector2.GetHashCode()));
vector2.Altitude = null;
Assert.That(vector1, Is.Not.EqualTo(vector2));
vector2.Altitude = 3.0;
vector2.Latitude = 3.0;
Assert.That(vector1, Is.Not.EqualTo(vector2));
}
示例3: Main
static void Main()
{
var vect1 = new Vector(3.0, 3.0, -10.0);
var vect2 = new Vector(3.0, 3.0, -10.0);
var vect3 = new Vector(2.0, 3.0, 6.0);
WriteLine($"vect1 == vect2 returns {(vect1 == vect2)}");
WriteLine($"vect1 == vect3 returns {(vect1 == vect3)}");
WriteLine($"vect2 == vect3 returns {(vect2 == vect3)}");
WriteLine();
WriteLine($"vect1 != vect2 returns {(vect1 != vect2)}");
WriteLine($"vect1 != vect3 returns {(vect1 != vect3)}");
WriteLine($"vect2 != vect3 returns {(vect2 != vect3)}");
var vect4 = new Vector(5.0, 2.0, 0);
var vect5 = new Vector(2.0, 5.0, 0);
WriteLine(vect4.GetHashCode());
WriteLine(vect5.GetHashCode());
}
示例4: EqualsAndHashCode
public void EqualsAndHashCode()
{
Vector vector1 = new Vector(new double[] { 1.0, 2.0, 3.0 });
Vector vector2 = new Vector(new double[] { 1.0, 2.0, 3.0 });
Vector vector3 = new Vector(new double[] { 1.0, 2.0, 3.0, 4.0 });
Vector vector4 = new Vector(new double[] { 1.0, 2.0, 4.0 });
Assert.IsTrue(vector1.Equals(vector2));
Assert.IsTrue(vector2.Equals(vector1));
Assert.AreEqual(vector2.GetHashCode(), vector1.GetHashCode());
Assert.IsFalse(vector1.Equals(vector3));
Assert.IsFalse(vector1.Equals(vector4));
Assert.IsFalse(vector3.Equals(vector1));
Assert.IsFalse(vector4.Equals(vector1));
Assert.IsFalse(vector1.Equals(null));
Assert.IsFalse(vector1.Equals(42));
Assert.IsFalse(vector1.Equals("foo"));
}
示例5: TestVectorHashcode
public void TestVectorHashcode()
{
var v = new Vector<string, int> { { "x", 1 }, { "y", -2 } };
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
v.GetHashCode();
}
示例6: Vector_GetHashCode_returns_same_hash_for_same_object
public void Vector_GetHashCode_returns_same_hash_for_same_object()
{
var v1 = new Vector(1.0f, 1.2f, 1.9f);
var v2 = v1;
var hash1 = v1.GetHashCode();
var hash2 = v2.GetHashCode();
Assert.AreEqual(hash1, hash2);
}
示例7: Vector_GetHashCode_returns_different_hashes_for_different_objects
public void Vector_GetHashCode_returns_different_hashes_for_different_objects()
{
var v1 = new Vector(1.0f, 1.2f, 1.9f);
var v2 = new Vector(-1.0f, -1.2f, -1.9f);
var hash1 = v1.GetHashCode();
var hash2 = v2.GetHashCode();
Assert.AreNotEqual(hash1, hash2);
}
示例8: Vector_GetHashCode_returns
public void Vector_GetHashCode_returns()
{
var v = new Vector(1.0f, 1.2f, 1.9f);
v.GetHashCode();
}