本文整理汇总了C#中IOrderedEnumerable.Last方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderedEnumerable.Last方法的具体用法?C# IOrderedEnumerable.Last怎么用?C# IOrderedEnumerable.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderedEnumerable
的用法示例。
在下文中一共展示了IOrderedEnumerable.Last方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DisplayPackageViewModel
public DisplayPackageViewModel(Package package, IOrderedEnumerable<Package> packageHistory, bool isVersionHistory)
: base(package)
{
Copyright = package.Copyright;
if (!isVersionHistory)
{
Dependencies = new DependencySetsViewModel(package.Dependencies);
PackageVersions = packageHistory.Select(p => new DisplayPackageViewModel(p, packageHistory, isVersionHistory: true));
}
DownloadCount = package.DownloadCount;
LastEdited = package.LastEdited;
if (!isVersionHistory && packageHistory.Any())
{
// calculate the number of days since the package registration was created
// round to the nearest integer, with a min value of 1
// divide the total download count by this number
TotalDaysSinceCreated = Convert.ToInt32(Math.Max(1, Math.Round((DateTime.UtcNow - packageHistory.Last().Created).TotalDays)));
DownloadsPerDay = TotalDownloadCount / TotalDaysSinceCreated; // for the package
}
else
{
TotalDaysSinceCreated = 0;
DownloadsPerDay = 0;
}
}
示例3: GetStatusColor
private static object GetStatusColor(DateTime dateDue, IOrderedEnumerable<Data.Model.FollowUpStatus> statuses)
{
foreach (var status in statuses)
{
if ((dateDue.Date - DateTime.Today).TotalDays >= status.NumberOfDays)
{
return status.Color;
}
}
return statuses.Last().Color;
}
示例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));
}
}
示例5: ArchiveInvocation
private Task ArchiveInvocation(IOrderedEnumerable<InvocationState.InvocationRow> invocationHistory)
{
var latest = invocationHistory.Last();
string name = String.Format(
"{0}_{1}_{2}.json",
latest.Job,
latest.UpdatedAt.ToString("s"),
latest.Id.ToString("N").ToLowerInvariant());
return _archiveContainer.UploadJsonBlob(name, invocationHistory.ToArray());
}