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


C# IReadOnlyCollection.Average方法代码示例

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


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

示例1: 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


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