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


C# Calculator.IsWithin方法代码示例

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


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

示例1: FindCitiesWithRadius

        public void FindCitiesWithRadius()
        {
            var providerCoventry = new Provider() { Name = "Coventry", Location = new Location() { Lat = 52.406822, Long = -1.519692999999961 }, Radius = 30 };
            var rugby = new Location()
                                 {
                                     Lat = 52.370878,
                                     Long = -1.2650320000000193
            };

            var warwik = new Location()
            {
                Lat = 52.28231599999999,
                Long = -1.5849269999999933
            };
            var leicester = new Location(){Lat = 52.6368778,Long = -1.1397591999999577};

            var london = new Location() { Lat = 51.5073509, Long = -0.12775829999998223 };

            var calculator = new Calculator();

            // Rugby and Warwik is closer than 30 km to Coventry
            var rugby_yes = calculator.IsWithin(rugby, providerCoventry.Location, providerCoventry.Radius);
            var warwik_yes = calculator.IsWithin(warwik, providerCoventry.Location, providerCoventry.Radius);

            // Leicester is further away than 30 km
            var leicester_no = calculator.IsWithin(leicester, providerCoventry.Location, providerCoventry.Radius);

            Assert.IsTrue(rugby_yes);
            Assert.IsTrue(warwik_yes);
            Assert.IsFalse(leicester_no);


        }
开发者ID:froberg,项目名称:FindProviders,代码行数:33,代码来源:UnitTest1.cs

示例2: TestWith1millionCalculations

        public void TestWith1millionCalculations()
        {
            var providerCoventry = new Provider() { Name = "Coventry", Location = new Location() { Lat = 52.406822, Long = -1.519692999999961 }, Radius = 30 };
            var rugby = new Location() { Lat = 52.370878,Long = -1.2650320000000193 };

            var calculator = new Calculator();
            var timer = Stopwatch.StartNew();
            for (int i = 0; i < 1000000; i++)
            {
                calculator.IsWithin(rugby, providerCoventry.Location, providerCoventry.Radius);
            }
            timer.Stop();
            var x = timer.Elapsed;
            var b = x.Milliseconds < 1000;
            System.Console.WriteLine(x.Milliseconds);
            Assert.IsTrue(b);

            // Takes les than 400 illiseconds
        }
开发者ID:froberg,项目名称:FindProviders,代码行数:19,代码来源:UnitTest1.cs


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