当前位置: 首页>>代码示例>>C#>>正文


C# Vector2.GetHashCode方法代码示例

本文整理汇总了C#中System.Vector2.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.GetHashCode方法的具体用法?C# Vector2.GetHashCode怎么用?C# Vector2.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Vector2的用法示例。


在下文中一共展示了Vector2.GetHashCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetHashCode

 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());
     }
 }
开发者ID:jeske,项目名称:agg-sharp,代码行数:28,代码来源:UnitTests.cs

示例2: Test_Equals

        public void Test_Equals()
        {
            var a = new Vector2 (1, 2.00001f);
            var b = new Vector2 (1, 2.00002f);

            Assert.IsTrue (a.Equals (b));   // 誤差を許容する比較
            Assert.IsFalse (a == b);        // 厳密な比較
            Assert.AreNotEqual (a.GetHashCode (), b.GetHashCode ()); // ハッシュは厳密な比較を基準
        }
开发者ID:weimingtom,项目名称:erica,代码行数:9,代码来源:TestVector2.cs

示例3: OrderByHash

        private static KeyValuePair<Vector2, Vector2> OrderByHash(Vector2 a, Vector2 b)
        {
            var ah = a.GetHashCode();
            var bh = b.GetHashCode();

            //Check order
            if (ah < bh)
                return new KeyValuePair<Vector2, Vector2>(a, b);
            else
                return new KeyValuePair<Vector2, Vector2>(b, a);
        }
开发者ID:martindevans,项目名称:CGAL_StraightSkeleton_Wrapper,代码行数:11,代码来源:StraightSkeleton.cs

示例4: Vector2GetHashCodeTest

        public void Vector2GetHashCodeTest()
        {
            Vector2 target = new Vector2(1.0f, 2.0f);

            int expected = target.X.GetHashCode() + target.Y.GetHashCode();
            int actual;

            actual = target.GetHashCode();

            Assert.AreEqual(expected, actual, "Vector2.GetHashCode did not return the expected value.");
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:11,代码来源:Vector2Test.cs


注:本文中的System.Vector2.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。