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


C# IOrderedEnumerable.ElementAt方法代码示例

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


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

示例1: Percentile

        private double Percentile(IOrderedEnumerable<double> sortedData, double p)
        {
            int count = sortedData.Count();
            if (count == 0) return 0;
            if (count == 1) return sortedData.Last();
            if (p >= 100.0d) return sortedData.Last();

            double position = (count + 1) * p / 100d;
            double leftNumber, rightNumber;

            double n = p / 100d * (count - 1) + 1d;

            if (position >= 1)
            {
                leftNumber = sortedData.ElementAt((int)Math.Floor(n) - 1);
                rightNumber = sortedData.ElementAt((int)Math.Floor(n));
            }
            else
            {
                leftNumber = sortedData.First();
                rightNumber = sortedData.ElementAt(1);
            }

            if (Math.Abs(leftNumber - rightNumber) < Double.Epsilon)
                return leftNumber;
            else
            {
                double part = n - Math.Floor(n);
                return leftNumber + part*(rightNumber - leftNumber);
            }
        }
开发者ID:demonix,项目名称:iPoint.ServiceStatistics,代码行数:31,代码来源:PercentileAggregationOperation.cs

示例2: GetListOfTrades

        private List<string> GetListOfTrades(string player, IOrderedEnumerable<KeyValuePair<string, double>> tradeList, bool topDown)
        {
            List<string> results = new List<string>();

            if (topDown)
            {
                for (int i = 0; i < tradeList.Count(); i++)
                {
                    if (tradeList.ElementAt(i).Key == player)
                    {
                        break;
                    }

                    results.Add(tradeList.ElementAt(i).Key);
                }
            }
            else
            {
                for (int i = tradeList.Count() - 1; i >= 0; i--)
                {
                    if (tradeList.ElementAt(i).Key == player)
                    {
                        break;
                    }

                    results.Add(tradeList.ElementAt(i).Key);
                }
            }
            return results;
        }
开发者ID:spazer,项目名称:FPL_Calculator,代码行数:30,代码来源:Stats.cs

示例3: GetQuartile

        private static double GetQuartile(IOrderedEnumerable<double> list, double quartile)
        {
            double result;

            // Get roughly the index
            double index = quartile * (list.Count() + 1);

            // Get the remainder of that index value if exists
            double remainder = index % 1;

            // Get the integer value of that index
            index = Math.Floor(index) - 1;

            if (remainder.Equals(0))
            {
                // we have an integer value, no interpolation needed
                result = list.ElementAt((int)index);
            }
            else
            {
                // we need to interpolate
                double value = list.ElementAt((int)index);
                double interpolationValue = value
                    .Interpolate(list.ElementAt((int)(index + 1)), remainder);

                result = value + interpolationValue;
            }

            return result;
        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:30,代码来源:MathUtil.cs

示例4: AddCorners

 private void AddCorners(IOrderedEnumerable<Pixel> cornerCandidates)
 {
     if (cornerCandidates.Count() > 50)
     {
         //First and Last point are corners
         MassureAngleAndAddCorner(cornerCandidates.First());
         MassureAngleAndAddCorner(cornerCandidates.Last());
     }
     else
     {
         // middle point is corner
         int index = cornerCandidates.Count() / 2;
         MassureAngleAndAddCorner(cornerCandidates.ElementAt(index));
     }
 }
开发者ID:rerezz,项目名称:Digitale-Bildbearbeitung,代码行数:15,代码来源:ImageObject.cs


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