本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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));
}
}