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


C# SortedDictionary.Sum方法代码示例

本文整理汇总了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);
 }
开发者ID:IamMan,项目名称:ModelingSignals,代码行数:57,代码来源:PotentialMethod.cs

示例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));
//.........这里部分代码省略.........
开发者ID:tojoirinah,项目名称:Refonte-Recueil-One,代码行数:101,代码来源:FoxitPDFGenerator.cs


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