本文整理汇总了C#中SortedDictionary.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.Sum方法的具体用法?C# SortedDictionary.Sum怎么用?C# SortedDictionary.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.Sum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: calcSignal
public override MethodResult calcSignal(string signal, int c)
{
if (signal.Length == 1)
{
return new MethodResult(0, 0, 0, 0, 0);
}
IDictionary<int, int> terms = new SortedDictionary<int, int>();
int term00 = 0;
int term11 = 2;
var nowTerm = -1;
for (var i = 0; i < signal.Length; i++)
{
if (signal[i] == '0')
{
if (nowTerm != 0)
{
if (term00 > 0)
{
term11 *= 2;
if (term11 > 0 && !terms.ContainsKey(term11))
{
terms.Add(term11, 0);
}
terms[term11]++;
}
term00 = 0;
nowTerm = 0;
}
term00++;
continue;
}
if (signal[i] == '1')
{
if (nowTerm != 3)
{
if (term00 > 0)
{
term00 *= 2;
if (!terms.ContainsKey(term00))
{
terms.Add(term00, 0);
}
terms[term00]++;
}
term00 = 0;
nowTerm = 3;
}
term11++;
}
}
double bit = 1.0 / c ;
double fa = terms.Sum(term => 1.0 / (term.Key * bit) * term.Value) / terms.Sum(term => term.Value);
double f0 = 1.0 / terms.Keys.Min() / bit;
double fn = 1.0 / terms.Keys.Max() / bit;
double fb = 7.0 * f0;
return new MethodResult(f0, fn, fb, fb - fn, fa);
}
示例2: AddLineChart
public string AddLineChart(
float x,
ref float y,
float width,
float height,
string[] seriename,
SortedDictionary<DateTime, double> valorisationdata,
Dictionary<DateTime, Tuple<double, double>> investissementandretraitdata = null,
System.Action afficheLabelFunction = null,
string datereleve=""
)
{
const string axeformat = "0.### 'K€'";
var logdata = string.Empty;
var labelFont = 9;
if ((valorisationdata == null || valorisationdata.Count == 0) &&
(investissementandretraitdata == null || investissementandretraitdata.Count == 0))
{
return logdata;
}
var sumvalorisation = valorisationdata.Sum(c => c.Value);
var summvt = investissementandretraitdata == null || investissementandretraitdata.Count == 0 ? 0 : investissementandretraitdata.Sum(d => d.Value.Item1 + d.Value.Item2);
if (sumvalorisation == 0 && summvt == 0)
return logdata;
if (afficheLabelFunction != null)
afficheLabelFunction();
y += 40;
Chart chart = new Chart(x, y, width, height);
chart.Legends.Placement = LegendPlacement.TopCenter;
PlotArea plotArea = chart.PrimaryPlotArea;
Legend legend = chart.Legends.Add(2, 3, 10, 10);
legend.Visible = false;
var legendwidth = 100;
chart.LeftPadding = -45;
//
//
//
var colorValorisation = "#094DEE";//9FCECE
//var colorInvestissement = "#983298";
//var colorRetrait = "#E0B64B";
//
//
//
var yAxisValorisation = new NumericYAxis();
yAxisValorisation.AnchorType = YAxisAnchorType.Left;
plotArea.YAxes.Add(yAxisValorisation);
plotArea.YAxes.DefaultNumericAxis = yAxisValorisation;
//
//
//
IndexedLineSeries lineValorisation = new IndexedLineSeries(seriename[0], null, yAxisValorisation, new WebColor(colorValorisation));
var _abs = x - 20;
AddRectangle(_abs, y - 15, 10, 2, colorValorisation);
AddLabelArialBold(seriename[0], _abs + 15, y - 20, 200, 50, labelFont);
//
//
//
IndexedColumnSeries lineInvestisstement = null;
IndexedColumnSeries lineRetrait = null;
plotArea.Series.Add(lineValorisation);
//
//
//
var dateReleve = valorisationdata.Keys.Last();
DateTime.TryParseExact(datereleve, "dd/MM/yyyy",
CultureInfo.InvariantCulture,
DateTimeStyles.None, out dateReleve);
//
if (datereleve != "")
{
var tmpDictionnary = valorisationdata.Where(x1 => x1.Key <= dateReleve).ToDictionary(xa => xa.Key, xa => xa.Value);
if (tmpDictionnary.Count > 0)
{
valorisationdata.Clear();
foreach (var newVal in tmpDictionnary)
{
valorisationdata.Add(newVal.Key, newVal.Value);
}
}
}
//
//
//
#region Legend
var dateabcisses = new List<DateTime>();
if (seriename.Length == 3 && investissementandretraitdata != null && investissementandretraitdata.Count > 0)
{
//
//si le montant de l'investissement et de retrait est inferieur à 10% de la valeur de compte
//
var valorisationmax10pourcent = valorisationdata.Values.Max() * 10 / 100;
var invesorretraitmax = Math.Max(investissementandretraitdata.Values.Max(x1 => x1.Item1), investissementandretraitdata.Values.Max(x2 => x2.Item2));
//.........这里部分代码省略.........