本文整理汇总了C#中SortedDictionary.ToSortedDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.ToSortedDictionary方法的具体用法?C# SortedDictionary.ToSortedDictionary怎么用?C# SortedDictionary.ToSortedDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.ToSortedDictionary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataSet
private List<SortedDictionary<double, double>> GetDataSet(DataSet ds)
{
var res = new SortedDictionary<double, List<double>>();
if (ds.Data!=null && Enumerable.Any(ds.Data))
foreach (var p in ds.Data)
{
double day = DateTimeAxis.ToDouble(p.Key);
double groupDay = day;
switch (ds.Grouping)
{
case GroupingOptions.none:
groupDay = DateTimeAxis.ToDouble(p.Key);
break;
case GroupingOptions.minutes:
groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour).AddMinutes(p.Key.Minute));
break;
case GroupingOptions.quarterly:
var min = 0;
if (p.Key.Minute < 30) min = 15;
if (p.Key.Minute < 45) min = 30;
if (p.Key.Minute < 60) min = 45;
groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour).AddMinutes(min));
break;
case GroupingOptions.hourly:
groupDay = DateTimeAxis.ToDouble(p.Key.Date.AddHours(p.Key.Hour));
break;
case GroupingOptions.daily:
groupDay = DateTimeAxis.ToDouble(p.Key.Date);
break;
case GroupingOptions.weekly:
groupDay = DateTimeAxis.ToDouble(p.Key.GetDateTimeForDayOfWeek(DayOfWeek.Monday));
break;
case GroupingOptions.monthly:
groupDay = DateTimeAxis.ToDouble(p.Key.GetFirstDayOfTheMonth());
break;
case GroupingOptions.yearly:
groupDay = DateTimeAxis.ToDouble(p.Key.GetFirstDayOfTheYear());
break;
}
if (!res.ContainsKey(groupDay)) res[groupDay] = new List<double>();
res[groupDay].Add(p.Value);
}
else if (ds.DData != null)
{
return new List<SortedDictionary<double, double>>() { ds.DData };
}
SortedDictionary<double, double> r = new SortedDictionary<double, double>();
switch (ds.GroupingOperation)
{
case GroupingOperations.count:
r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Count)).ToSortedDictionary(k => k.Key, k => k.Value);
break;
case GroupingOperations.maximum:
r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Max())).ToSortedDictionary(k => k.Key, k => k.Value);
break;
case GroupingOperations.minimum:
r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Min())).ToSortedDictionary(k => k.Key, k => k.Value);
break;
case GroupingOperations.average:
r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Average())).ToSortedDictionary(k => k.Key, k => k.Value);
break;
case GroupingOperations.total:
r = (from n in res select new KeyValuePair<double, double>(n.Key, n.Value.Sum())).ToSortedDictionary(k => k.Key, k => k.Value);
break;
}
SortedDictionary<double, double> f = new SortedDictionary<double, double>();
switch (ds.FunctionOperation)
{
case FunctionOperations.none:
f = r;
break;
case FunctionOperations.reduction:
{
var m = new MathFunctions();
var temp = (from n in r select new Point(n.Key, n.Value)).ToList();
var euclistx = new List<double>();
var euclisty = new List<double>();
for (int i = 0; i < temp.Count - 1; i++)
{
euclistx.Add(Math.Sqrt((temp[i].X - temp[i + 1].X)*(temp[i].X - temp[i + 1].X)));
euclisty.Add(Math.Sqrt((temp[i].Y - temp[i + 1].Y)*(temp[i].Y - temp[i + 1].Y)));
}
var thresholdx = Convert.ToDouble(euclistx.Average());
var thresholdy = Convert.ToDouble(euclisty.Average());
var dp = m.DouglasPeuckerReduction(temp, 10*thresholdx);
f = (from n in dp select new KeyValuePair<double, double>(n.X, n.Y)).ToSortedDictionary(k => k.Key,
k => k.Value);
}
break;
case FunctionOperations.auto:
{
if (ds.ReducedData == null)
ds.ReducedData = mf.CalculateReduction(r, 0.95); ;
f = ds.ReducedData;
//.........这里部分代码省略.........