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


C# ICollection.Sum方法代码示例

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


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

示例1: OverallScore

 public OverallScore(ICollection<CpScore> cpScores, CpScore latestCpScore, int latestCp)
 {
     _cps = cpScores.Count;
     EnlightenedScoreTotal = cpScores.Sum(item => item.EnlightenedScore);
     ResistanceScoreTotal = cpScores.Sum(item => item.ResistanceScore);
     LastCpScore = latestCpScore;
     LastCp = latestCp;
 }
开发者ID:CecilCable,项目名称:Ingress-ScoreKeeper,代码行数:8,代码来源:OverallScore.cs

示例2: TimingStatSummary

 public TimingStatSummary(ICollection<TimingStat> stats, DateTime start, DateTime end) {
     Stats = stats;
     Count = Stats.Sum(s => s.Count);
     MinDuration = Stats.Min(s => s.MinDuration);
     MaxDuration = Stats.Max(s => s.MaxDuration);
     TotalDuration = Stats.Sum(s => s.TotalDuration);
     AverageDuration = Count > 0 ? (double)TotalDuration / Count : 0;
     StartTime = start;
     EndTime = end;
 }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:10,代码来源:TimingStat.cs

示例3: GaugeStatSummary

 public GaugeStatSummary(ICollection<GaugeStat> stats, DateTime start, DateTime end) {
     Stats = stats;
     Count = Stats.Sum(s => s.Count);
     Total = Stats.Sum(s => s.Total);
     Last = Stats.Last().Last;
     Min = Stats.Min(s => s.Min);
     Max = Stats.Max(s => s.Max);
     StartTime = start;
     EndTime = end;
     Average = Count > 0 ? Total / Count : 0;
 }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:11,代码来源:GaugeStat.cs

示例4: GetQuote

        public QuoteCalculationResult GetQuote(int loanAmount, ICollection<Offer> offers)
        {
            if (null == offers)
            {
                throw new ArgumentNullException(nameof(offers));
            }

            if (offers.Sum(x => x.CashAvailable) < loanAmount)
            {
                return null;
            }

            var totalRepayment = CalculateTotalToPay(loanAmount, offers);

            var quote = (totalRepayment - loanAmount) / loanAmount;

            var monthlyRepayment = loanAmount * (1 + quote) / LoanLengthInMonths;

            return new QuoteCalculationResult
            {
                LoanAmount = loanAmount,
                Quote = quote,
                MonthlyRepayment = monthlyRepayment,
                TotalRepayment = totalRepayment
            };
        }
开发者ID:skorunka,项目名称:ZopaTechnicalTestDeveloper,代码行数:26,代码来源:QuoteCalculator.cs

示例5: StdDev

 private double StdDev(ICollection<double> vals)
 {
     double sum = vals.Sum();
     double avg = sum / vals.Count;
     double sumSquaredError = 0;
     foreach (double x in vals)
         sumSquaredError += (x - avg) * (x - avg);
     return Math.Sqrt(sumSquaredError / vals.Count);
 }
开发者ID:shilrobot,项目名称:emu6502,代码行数:9,代码来源:BenchmarkDlg.cs

示例6: Reload

        public void Reload()
        {
            var doc = new XmlDocument();
            doc.Load("/res/gutter.xml".AsAbsolute());

            elements = doc.SelectNodes("/gutter/element[@visible=\"true\"]").Cast<XmlElement>()
                .Select(x => (IGutterElement)Assembly.GetExecutingAssembly().CreateInstance(x.GetAttribute("class")))
                .ToList();

            Width = elements.Sum(x => x.Width);
        }
开发者ID:chrisforbes,项目名称:corfu,代码行数:11,代码来源:Gutter.cs

示例7: BuildMany

 public static SuffixArray BuildMany(ICollection<Nucleotide[]> fragments)
 {
     var tmp = new byte[fragments.Count + fragments.Sum(p => p.Length)];
     int i = 0;
     foreach (var fragment in fragments)
     {
         foreach (var nucleotide in fragment)
             tmp[i++] = (byte) nucleotide;
         tmp[i++] = (byte)Nucleotide.End;
     }
     tmp[i - 1]++;
     var sfx = new SuffixArray(tmp);
     return sfx;
 }
开发者ID:supcry,项目名称:MotifSeeker,代码行数:14,代码来源:SuffixBuilder.cs

示例8: BuildMany2

 public static TextComparer BuildMany2(ICollection<Nucleotide[]> fragments, int minGroupSize = 0)
 {
     var tmp = new byte[fragments.Count + fragments.Sum(p => p.Length)];
     int i = 0;
     foreach (var fragment in fragments)
     {
         foreach (var nucleotide in fragment)
             tmp[i++] = (byte)nucleotide;
         tmp[i++] = (byte)Nucleotide.End;
     }
     tmp[i - 1]++;
     var sfx = new SuffixArray(tmp, minGroupSize);
     return new TextComparer(tmp, sfx);
 }
开发者ID:supcry,项目名称:MotifSeeker,代码行数:14,代码来源:SuffixBuilder.cs

示例9: RequeryIfRequired

        private IEnumerable<LocationGroup> RequeryIfRequired(ICollection<LocationGroup> results, string addressQuery, ILocationGroupingStrategy groupingStrategy)
        {
            var locationsSum = results.Sum(g => g.LocationsCount);

            if (!results.Any() || locationsSum == 0)
                return results;

            if (results.HasSingleGroup() || locationsSum < GROUPING_THRESHOLD) {
                var groupingStrategyBuilder = new LocationGroupingStrategyBuilder(_locationQueryFields.PrimaryText)
                    .ThenBy(_locationQueryFields.SecondaryText)
                    .ThenBy(_locationQueryFields.HouseNumber)
                    .ThenBy(groupingStrategy);

                return _groupRepository.FindGroupedLocations(addressQuery, groupingStrategyBuilder.Build());
            }

            return results;
        }
开发者ID:NHSChoices,项目名称:location-service,代码行数:18,代码来源:LocationSearchService.cs

示例10: ConsumptionSummary

        public ConsumptionSummary(ICollection<ConsumptionItem> consumptionItems)
        {
            Total = consumptionItems.Count;
            TotalCost = consumptionItems.Sum(c => c.Cost);
            consumptionItems.ToList().ForEach(c =>
            {
                var user = c.Consumer as User;
                if (c.Status == ValueObject.ItemStatus.Done)
                {
                    PaidUsers.Add(user);
                    PaidCost += c.Cost;
                }
                else
                {
                    UnpaidUsers.Add(user);
                    UnpaidCost += c.Cost;
                }

            });
        }
开发者ID:xiezhenhao,项目名称:NotifyApp,代码行数:20,代码来源:ConsumptionSummary.cs

示例11: Append

		public Task<AppendResult> Append(string stream, ICollection<Message> data) {
			stream = stream.ToLowerInvariant();
			var hash = stream.GetHashCode();
			var segment = Get(stream);

			return _scheduler.StartNew(hash, () => {
				using (Metrics.StartTimer("storage.append.time")) {
					var append = segment.Append(data);

					Metrics.Counter("storage.append.events", data.Count);
					Metrics.Counter("storage.append.bytes", data.Sum(mw => mw.Value.Length));

					// current position of a stream
					Metrics.Gauge("stream." + stream, append.Position);

					// number of appends to a stream
					Metrics.Counter("stream." + stream + ".append.ok");
					Metrics.Counter("stream." + stream + ".append.events", data.Count);

					return append;
				}
			});
		}
开发者ID:perokvist,项目名称:messageVault,代码行数:23,代码来源:MessageWriteScheduler.cs

示例12: CanCloseTheGame

        public bool CanCloseTheGame(PlayerTurnContext context, ICollection<Card> playerCards)
        {
            // Stalker has A and 10 from trumps, certain ammount of points and some other winning cards.
            var hasHighTrumps = this.cardHolder.AllCards[context.TrumpCard.Suit][CardType.Ace] == CardStatus.InStalker &&
                                      this.cardHolder.AllCards[context.TrumpCard.Suit][CardType.Ten] == CardStatus.InStalker;

            // Stalker has 40 and is already above certain points.
            var has40 = this.cardHolder.AllCards[context.TrumpCard.Suit][CardType.King] == CardStatus.InStalker
                         && this.cardHolder.AllCards[context.TrumpCard.Suit][CardType.Queen] == CardStatus.InStalker;

            var hasEnoughAfterAnounce = context.FirstPlayerRoundPoints > StalkerHelperConstants.CloseGamePointsBeforeAnnounce;

            var hasNecessaryPoints = playerCards.Sum(c => c.GetValue()) + context.FirstPlayerRoundPoints > StalkerHelperConstants.CloseGameMinimumPoints;

            var sureWiningCards = playerCards.Count(card => !this.ContainsGreaterCardThan(card, CardStatus.InDeckOrEnemy));

            if (has40 && hasEnoughAfterAnounce)
            {
                return true;
            }

            return hasHighTrumps && hasNecessaryPoints && sureWiningCards > 0;
        }
开发者ID:M-Yankov,项目名称:S.T.A.L.K.E.R,代码行数:23,代码来源:StalkerHelper.cs

示例13: CombineByte

 protected static byte[] CombineByte(ICollection<byte[]> buffers)
 {
     Int32 length = buffers.Sum(tempbyte => tempbyte.Length);
     Byte[] result = new Byte[length];
     Int32 offset = 0;
     foreach (byte[] buffer in buffers)
     {
         Buffer.BlockCopy(buffer, 0, result, offset, buffer.Length);
         offset += buffer.Length;
     }
     return result;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:12,代码来源:NetProxy.cs

示例14: AddRow

        private void AddRow(ICollection<IControl> controls, ICollection<int> percentWidths, double y)
        {
            if (controls.Count != percentWidths.Count)
            {
                throw new ArgumentException("Control count have to be equal to percentWidths count");
            }

            if (percentWidths.Sum() != 100)
            {
                throw new ArgumentException("Percents sum have to be 100");
            }

            double left = 0;
            double maxWidth = Rect.Width - MarginLeft - MarginRight;

            var controlWidthPairs = controls.Zip(percentWidths, (c, p) => new {Control = c, PercentWidth = p});
            foreach (var pair in controlWidthPairs)
            {
                double x = left;
                double width = maxWidth*pair.PercentWidth/100;
                double height = pair.Control.Rect.Height;

                pair.Control.Rect = new XRect(x, y, width, height);
                left += width;
                Controls.Add(pair.Control);
            }

            _currentY = controls.Select(x => (x.Rect.Height + x.Rect.Y)).Max();
            Rect = new XRect(Rect.X, Rect.Y, Rect.Width, _currentY + MarginTop + MarginBottom);
        }
开发者ID:batas2,项目名称:PdfSharp.Controls,代码行数:30,代码来源:Groupbox.cs

示例15: WritePathList

        private void WritePathList(ICollection<string> pathList)
        {
            int pathSize = pathList.Sum(path => path.Length + 1); // + 1, as all strings are null terminated
            int pathListSize = 8 + 8 * pathList.Count + pathSize;
            archiveWriter.Write(pathListSize);
            archiveWriter.Write(pathList.Count);

            int current = 8 + pathList.Count * 8;
            foreach (var path in pathList)
            {
                archiveWriter.Write(current);
                archiveWriter.Write(path.Length + 1);
                current += path.Length + 1; // +1, as all strings are null terminated
            }

            foreach (var path in pathList)
            {
                archiveWriter.WriteNullTerminatedString(path);
            }
        }
开发者ID:Translator5,项目名称:TuxLoL,代码行数:20,代码来源:RiotArchiveWriter.cs


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