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


C# IDictionary.Sum方法代码示例

本文整理汇总了C#中IDictionary.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.Sum方法的具体用法?C# IDictionary.Sum怎么用?C# IDictionary.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


在下文中一共展示了IDictionary.Sum方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RosterAssignmentAnalyzer

        public RosterAssignmentAnalyzer(IDictionary<PositionAbbreviation, RosterPosition> rosterPositions, ICollection<Player> availablePlayers)
        {
            if (availablePlayers.Count > rosterPositions.Sum(rp => rp.Value.Count))
            {
                throw new ArgumentException("There are more players than roster positions available.");
            }

            _rosterPositions = rosterPositions;
            _availablePlayers = availablePlayers;
        }
开发者ID:sconno05,项目名称:yahoo-fantasy-football-tools,代码行数:10,代码来源:RosterAssignmentAnalyzer.cs

示例2: Value

        public double Value(IDictionary<string, double> p1, IDictionary<string, double> p2)
        {
            double dot = 0;

            string[] keys = p2.Keys.ToArray();

            foreach (string key in keys)
                if (p1.ContainsKey(key))
                    dot += Math.Sqrt(p1[key] * p2[key]);

            return -dot / Math.Sqrt(p1.Sum(c => c.Value)) * Math.Sqrt(p2.Sum(c => c.Value));
        }
开发者ID:turboNinja2,项目名称:Rob-The-Robot,代码行数:12,代码来源:InformationDiffusion.cs

示例3: GenerateReport

        static void GenerateReport(IDictionary<Uri, long> dump, IDictionary<string, long> errors)
        {
            var totalCount = dump.Sum(pair => pair.Value);
            var distinctCount = dump.Count;
            var errorCount = errors.Sum(pair => pair.Value);
            var top10 = dump.OrderByDescending(pair => pair.Value).Take(10).ToList();
            var top10Errors = errors.OrderByDescending(pair => pair.Value).Take(10).ToList();

            Console.Clear();

            Console.WriteLine($"Total Count:\t\t{totalCount}");
            Console.WriteLine($"Distinct Count:\t\t{distinctCount}");
            Console.WriteLine($"Error Count:\t\t{errorCount}");
            Console.WriteLine();
            Console.WriteLine("Top 10:");
            top10.ForEach(pair => Console.WriteLine($" ({pair.Value}) {pair.Key}"));Console.WriteLine();
            Console.WriteLine("Top 10 Errors:");
            top10Errors.ForEach(pair => Console.WriteLine($" ({pair.Value}) {pair.Key}"));
        }
开发者ID:LarsVonQualen,项目名称:DumbCrawler,代码行数:19,代码来源:Program.cs

示例4: Genie

 // ReSharper restore UnusedMember.Local
 public Genie(IDictionary<string, AnswerStatistic> answerStatistics, int answeringChoicesCount)
 {
     this.answerStatistics = answerStatistics;
     this.answeringChoicesCount = answeringChoicesCount;
     answersGuessedCount = answerStatistics.Sum(s => s.Value.AnswerCount);
     questionStatistics = answerStatistics.SelectMany(s => s.Value.AnsweredQuestionsById)
                             .GroupBy(p => p.Key)
                             .ToDictionary(g => g.Key, g => new QuestionStatistic
                                 {
                                     ChoicesFrequencies = g.Aggregate(new int[answeringChoicesCount], (curr, p) =>
                                         {
                                             for (int i = 0; i < answeringChoicesCount; i++)
                                             {
                                                 curr[i] += p.Value.ChoicesFrequencies[i];
                                             }
                                             return curr;
                                         })
                                 });
 }
开发者ID:VorobeY1326,项目名称:Bkinator,代码行数:20,代码来源:Genie.cs

示例5: getAlleleFreqs

        private Dictionary<Allele, double> getAlleleFreqs(IDictionary<Genotype, int> genotypeCounts)
        {
            // Get the total count of Alleles
            long totalPop = genotypeCounts.Sum(pair => (long)pair.Value);
            long totalAlleles = 2 * totalPop;

            // Get the count of each Allele (twice in homozygotes, once in heterozygotes)
            Dictionary<Allele, long> alleleCounts = new Dictionary<Allele, long>();
            Genotype[] genotypes = genotypeCounts.Keys.ToArray();
            foreach (Genotype g in genotypes) {
                int count = genotypeCounts[g];

                // Increment the first Allele's count
                if (alleleCounts.ContainsKey(g.Allele1))
                    alleleCounts[g.Allele1] += count;
                else
                    alleleCounts.Add(g.Allele1, count);

                // Increment the second Allele's count
                if (alleleCounts.ContainsKey(g.Allele2))
                    alleleCounts[g.Allele2] += count;
                else
                    alleleCounts.Add(g.Allele2, count);
            }

            // Divide by total to get Allele frequencies
            Dictionary<Allele, double> alleleFreqs = alleleCounts.ToDictionary(
                pair => pair.Key,
                pair => (double)pair.Value / (double)totalAlleles
            );
            return alleleFreqs;
        }
开发者ID:Rabadash8820,项目名称:HardyWeinberg,代码行数:32,代码来源:MainForm.cs

示例6: WriteHeader

        private void WriteHeader(StreamWriter sw, IDictionary<File, string> files, TypeDefinition[] types)
        {
            var total = files.Sum(x => x.Key.Annotations.Length);

            sw.WriteLine("<html>");
            sw.WriteLine("<head>");
            sw.WriteLine("<meta charset='utf-8' />");
            sw.WriteLine("<title>Warning Report</title>");
            sw.WriteLine("<link rel='stylesheet' type='text/css' href='report.css' />");
            sw.WriteLine("</head><body><div class='container'>");
            sw.WriteLine("<h1>Summary</h1>");
            sw.WriteLine("<table class='overview'>");
            sw.WriteLine("<colgroup>");
            sw.WriteLine("<col width='160' />");
            sw.WriteLine("<col />");
            sw.WriteLine("</colgroup>");
            sw.WriteLine("<tbody>");
            sw.WriteLine("<tr><th>Generated on:</th><td>" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "</td></tr>");

            WriteStats(sw, files, types, total);

            sw.WriteLine("</tbody>");
            sw.WriteLine("</table>");
            sw.WriteLine("<h1>Files</h1>");
        }
开发者ID:rjasica,项目名称:HtmlWarningsReportGenerator,代码行数:25,代码来源:IndexWriter.cs

示例7: GetWordCount

 private int GetWordCount(IDictionary<string, int> words)
 {
   return words.Sum(pair => pair.Value);
 }
开发者ID:miobioha,项目名称:WordCounter,代码行数:4,代码来源:StringExtensionTests.cs

示例8: RecordRowCounts

 /// <summary>
 /// Writes total captured rowcounts to log and graphite
 /// </summary>
 private void RecordRowCounts(IDictionary<string, long> changesCaptured)
 {
     long total = changesCaptured.Sum(x => x.Value);
     logger.Log("Total rowcount across all tables: " + total, LogLevel.Info);
     string key = string.Format("db.mssql_changetracking_counters.RowCountsMaster.{0}.{1}", Config.Master.Replace('.', '_'), Config.MasterDB);
     logger.Increment(key, total);
 }
开发者ID:mavencode01,项目名称:tesla,代码行数:10,代码来源:Master.cs


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