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


C# IReadOnlyCollection.Max方法代码示例

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


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

示例1: IndexCollection

        public IndexCollection(IReadOnlyCollection<Index> latest,
                                    IndexCollection previous,
                                    FileInfo info,
                                    Encoding encoding)
        {
            Info = info;
            Encoding = encoding;
            Count = latest.Select(idx => idx.LineCount).Sum();
            Indicies = latest.ToArray();
            Diff = Count - (previous?.Count ?? 0);
            
            //need to check whether
            if (previous == null)
            {
                ChangedReason = LinesChangedReason.Loaded;
                TailInfo = new TailInfo(latest.Max(idx => idx.End));
            }
            else
            {
                var mostRecent = latest.OrderByDescending(l => l.TimeStamp).First();
                ChangedReason = mostRecent.Type == IndexType.Tail
                                ? LinesChangedReason.Tailed
                                : LinesChangedReason.Paged;

             TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End));
            }
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:27,代码来源:IndexCollection.cs

示例2: GetCommonRoot

        private static string GetCommonRoot(IReadOnlyCollection<string> normalizedPaths)
        {
            if (normalizedPaths.Count == 0)
                return string.Empty;

            var maxPathLength = normalizedPaths.Max(s => s.Length);
            var longestPath = normalizedPaths.First(p => p.Length == maxPathLength)
                .Split(Path.DirectorySeparatorChar)
                .Select(p => p + Path.DirectorySeparatorChar);

            var result = string.Empty;

            foreach (var path in longestPath)
            {
                // If this is the first path segment we need check whether it's a valid
                // prefix of all paths.
                //
                // If it's not then it means there is no common root.

                if (result.Length == 0 && normalizedPaths.All(p => p.StartsWith(path)))
                {
                    result = path;
                    continue;
                }

                // We already have a path.
                //
                // In that case the combined path must be a valid prefix.

                var fullPath = Path.Combine(result, path);
                if (normalizedPaths.All(p => p.StartsWith(fullPath)))
                {
                    result = fullPath;
                    continue;
                }

                break;
            }

            return result;
        }
开发者ID:NN---,项目名称:nuproj,代码行数:41,代码来源:AssignSourceTargetPaths.cs

示例3: IndexCollection

        public IndexCollection(IReadOnlyCollection<Index> latest,
                                    IndexCollection previous,
                                    FileInfo info,
                                    Encoding encoding)
        {
            Info = info;
            Encoding = encoding;
            Count = latest.Select(idx => idx.LineCount).Sum();
            Indicies = latest.ToArray();
            Diff = Count - (previous?.Count ?? 0);

            //need to check whether
            if (previous == null)
            {
                TailInfo = new TailInfo(latest.Max(idx => idx.End));
            }
            else
            {
                TailInfo = new TailInfo(previous.Indicies.Max(idx => idx.End));
            }
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:21,代码来源:IndexCollection.cs

示例4: Analyze

        public IEnumerable<Fact> Analyze(IReadOnlyCollection<DiceRoll> statistics)
        {
            ICollection<Fact> facts = new Collection<Fact>();
            var statisticsCount = statistics.Count(); //check for real diceroll

            var successfulFact = new Fact
            {
                Description = "Count",
                Divident = statisticsCount,
                Divider = statisticsCount
            };
            facts.Add(successfulFact);

            var sameFact = new Fact
            {
                Description = "Same",
                Divident = statistics.Count(o => o.IsSameValue),
                Divider = statisticsCount
            };
            facts.Add(sameFact);

            var minSum = statistics.Min(o => o.Sum);
            var maxSum = statistics.Max(o => o.Sum);

            for (var i = minSum; i <= maxSum; i++)
            {
                var sumFact = new Fact
                {
                    Description = "Sum " + i,
                    Divident = statistics.Count(o => o.Sum == i),
                    Divider = statisticsCount
                };
                facts.Add(sumFact);
            }

            //add single value fact generation

            return facts;
        }
开发者ID:KefirNot,项目名称:VirtualMonopoly,代码行数:39,代码来源:DiceRollAnalyzer.cs

示例5: UpdateSegment

        public void UpdateSegment(IReadOnlyCollection<BikeData> lines)
        {
            var pointsInBatch = lines.Count;

            var previousNumberOfPoints = this.NumberOfPoints;

            this.NumberOfPoints += pointsInBatch;

            this.MaxSpeed = this.MaxSpeed > lines.Max(l => l.MaxSpeed) ? this.MaxSpeed : lines.Max(l => l.MaxSpeed);

            this.MaxSatellites = this.MaxSatellites > lines.Max(l => l.Satellites)
                                        ? this.MaxSatellites
                                        : lines.Max(l => l.Satellites);

            this.MaxRoll = this.MaxRoll > lines.Max(l => l.MaxRoll) ? this.MaxSpeed : lines.Max(l => l.MaxRoll);

            this.MaxPitch = this.MaxSpeed > lines.Max(l => l.MaxPitch) ? this.MaxPitch : lines.Max(l => l.MaxPitch);

            this.MaxTemperature = this.MaxTemperature > lines.Max(l => l.MaxTemperature)
                                         ? this.MaxTemperature
                                         : lines.Max(l => l.MaxTemperature);

            this.MaxBmp = this.MaxBmp > lines.Max(l => l.MaxBmp) ? this.MaxBmp : lines.Max(l => l.MaxBmp);

            this.MaxAccelerationX = this.MaxAccelerationX > lines.Max(l => l.MaxAccelerationX)
                                           ? this.MaxAccelerationX
                                           : lines.Max(l => l.MaxAccelerationX);

            this.MaxAccelerationY = this.MaxAccelerationY > lines.Max(l => l.MaxAccelerationY)
                                           ? this.MaxAccelerationY
                                           : lines.Max(l => l.MaxAccelerationY);

            this.MaxAccelerationZ = this.MaxAccelerationZ > lines.Max(l => l.MaxAccelerationZ)
                                           ? this.MaxAccelerationZ
                                           : lines.Max(l => l.MaxAccelerationZ);

            this.AverageSpeed = ((this.AverageSpeed * previousNumberOfPoints)
                                    + (lines.Average(l => l.AverageSpeed) * pointsInBatch))
                                   / (previousNumberOfPoints + pointsInBatch);

            this.AverageSatellites =
                Convert.ToInt32(
                    ((this.AverageSatellites * previousNumberOfPoints) + (lines.Average(l => l.Satellites) * pointsInBatch))
                    / (previousNumberOfPoints + pointsInBatch));

            this.AverageRoll = ((this.AverageRoll * previousNumberOfPoints)
                                   + (lines.Average(l => l.AverageRoll) * pointsInBatch))
                                  / (previousNumberOfPoints + pointsInBatch);

            this.AveragePitch = ((this.AveragePitch * previousNumberOfPoints)
                                    + (lines.Average(l => l.AveragePitch) * pointsInBatch))
                                   / (previousNumberOfPoints + pointsInBatch);

            this.AverageTemperature = ((this.AverageTemperature * previousNumberOfPoints)
                                          + (lines.Average(l => l.AverageTemperature) * pointsInBatch))
                                         / (previousNumberOfPoints + pointsInBatch);

            this.AverageBmp = ((this.AverageBmp * previousNumberOfPoints)
                                  + (lines.Average(l => l.AverageBmp) * pointsInBatch))
                                 / (previousNumberOfPoints + pointsInBatch);

            this.AverageAccelerationX = ((this.AverageAccelerationX * previousNumberOfPoints)
                                            + (lines.Average(l => l.AverageAccelerationX) * pointsInBatch))
                                           / (previousNumberOfPoints + pointsInBatch);

            this.AverageAccelerationY = ((this.AverageAccelerationY * previousNumberOfPoints)
                                            + (lines.Average(l => l.AverageAccelerationY) * pointsInBatch))
                                           / (previousNumberOfPoints + pointsInBatch);

            this.AverageAccelerationZ = ((this.AverageAccelerationZ * previousNumberOfPoints)
                                            + (lines.Average(l => l.AverageAccelerationZ) * pointsInBatch))
                                           / (previousNumberOfPoints + pointsInBatch);

            this.AverageAltitude = ((this.AverageAltitude * previousNumberOfPoints)
                                            + (lines.Average(l => l.GpsAltitude) * pointsInBatch))
                                           / (previousNumberOfPoints + pointsInBatch);
        }
开发者ID:morefun0302,项目名称:BikeTracker,代码行数:77,代码来源:TripSegment.cs

示例6: ActorRegistry

        public ActorRegistry(IReadOnlyCollection<Tuple<ActorDescriptor, IRingBuffer, ActorId>> actors)
        {
            if (actors.Count > ActorId.MaxValue)
            {
                throw new ArgumentException("To many actors");
            }

            var messageTypesOrdered = actors.Select(t => t.Item1)
                .SelectMany(d => d.HandledMessageTypes)
                .Distinct()
                .OrderBy(t => t.TypeHandle.Value.ToInt64())
                .ToArray();

            if (messageTypesOrdered.Length == 0)
            {
                throw new ArgumentException("The handled messages set is empty. This is a useless registry");
            }

            _messageTypeDiff = messageTypesOrdered.First().TypeHandle.Value.ToInt64() - 1;

            var ringsGroupedByMessageId = actors.SelectMany(
                t =>
                    t.Item1.HandledMessageTypes.Select(
                        messageType => new {MessageTypeId = GetMessageTypeId(messageType), Buffer = t.Item2}))
                .GroupBy(a => a.MessageTypeId)
                .ToArray();

            var buffers = new List<IRingBuffer>();
            AddPadding(buffers);

            var count = ringsGroupedByMessageId.Length;
            var keys = new int[count];
            var values = new Tuple<int, int>[count];
            var index = 0;

            foreach (var g in ringsGroupedByMessageId)
            {
                keys[index] = g.Key;
                var start = buffers.Count;
                buffers.AddRange(g.Select(tuple => tuple.Buffer));
                var end = buffers.Count;
                var length = end - start;

                values[index] = Tuple.Create(start, length);
                index += 1;
            }

            AddPadding(buffers);

            // create one table
            var bufferArray = buffers.ToArray();
            var valuesArray =
                values.Select(tuple => new ArraySegment<IRingBuffer>(bufferArray, tuple.Item1, tuple.Item2)).ToArray();

            _messageTypeToBuffers = new IntLookup<ArraySegment<IRingBuffer>>(keys, valuesArray);

            // by actor
            var max = actors.Max(t => t.Item3.Value);
            _buffersByActor = new IRingBuffer[max + 1];

            foreach (var actor in actors)
            {
                _buffersByActor[actor.Item3.Value] = actor.Item2;
            }
        }
开发者ID:Scooletz,项目名称:RampUp,代码行数:65,代码来源:ActorRegistry.cs


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