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


C# IEnumerable.Max方法代码示例

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


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

示例1: WriteHistory

        internal static void WriteHistory(IEnumerable<IEvent> history, RoomieCommandInterpreter interpreter)
        {
            var headers = new[] {"Time Stamp", "Entity", "Type", "Source", ""};
            var tableBuilder = new TextTable(new int[]
                {
                    Math.Max(history.Max(x => x.TimeStamp.ToLocalTime().ToString().Length), headers[0].Length),
                    Math.Max(history.Max(x => ((x.Entity == null || x.Entity.Name == null) ? string.Empty : x.Entity.Name).Length), headers[1].Length),
                    Math.Max(history.Max(x => ((x.Type == null) ? string.Empty : x.Type.Name).Length), headers[2].Length),
                    Math.Max(history.Max(x => ((x.Source == null || x.Source.Name == null) ? string.Empty : x.Source.Name).Length), headers[3].Length),
                    ExtraLength(history)
                });

            interpreter.WriteEvent(tableBuilder.StartOfTable(headers));

            foreach (var @event in history)
            {
                var extra = GetExtra(@event);

                var line = tableBuilder.ContentLine(
                    @event.TimeStamp.ToLocalTime().ToString(),
                    (@event.Entity == null) ? string.Empty : @event.Entity.Name,
                    (@event.Type == null) ? string.Empty : @event.Type.Name,
                    (@event.Source == null) ? string.Empty : @event.Source.Name,
                    extra
                    );

                interpreter.WriteEvent(line);
            }

            interpreter.WriteEvent(tableBuilder.EndOfTable());
        }
开发者ID:Mavtak,项目名称:roomie,代码行数:31,代码来源:ListEvents.cs

示例2: ChunkIsStable

 protected bool ChunkIsStable(IEnumerable<Zipping.Pair<int, int>> points)
 {
     const int maxVariance = 50;
     var xVariance = points.Max(p => p.First) - points.Min(p => p.First);
     var yVariance = points.Max(p => p.Second) - points.Min(p => p.Second);
     return xVariance < maxVariance && yVariance < maxVariance;
 }
开发者ID:mlidbom,项目名称:tobii,代码行数:7,代码来源:020_StreamProcessing.cs

示例3: ChunkIsStable

 protected bool ChunkIsStable(IEnumerable<Point> points)
 {
     const int maxVariance = 50;
     var xVariance = points.Max(p => p.X) - points.Min(p => p.Y);
     var yVariance = points.Max(p => p.X) - points.Min(p => p.Y);
     return xVariance < maxVariance && yVariance < maxVariance;
 }
开发者ID:mlidbom,项目名称:tobii,代码行数:7,代码来源:030-ReactiveExtensions.cs

示例4: MinimumOf

        public static BoundingBox MinimumOf(IEnumerable<BoundingBox> boxes)
        {
            decimal northmost = boxes.Max(b => b.North);
            decimal southmost = boxes.Min(b => b.South);
            decimal eastmost  = boxes.Max(b => b.East);
            decimal westmost  = boxes.Min(b => b.West);

            return new BoundingBox { North = northmost, South = southmost, East = eastmost, West = westmost };
        }
开发者ID:jncc,项目名称:topcat,代码行数:9,代码来源:BoundingBoxUtility.cs

示例5: SlidingBlockType

 public SlidingBlockType(IEnumerable<Point> subBlocks, int typeID)
 {
     SubBlocks = new ObservableCollection<Point>(subBlocks);
     if (subBlocks.Any())           // If sequence is not empty
     {
         SizeX = subBlocks.Max(t => t.X) + 1;
         SizeY = subBlocks.Max(t => t.Y) + 1;
         TypeID = typeID;
     }
 }
开发者ID:FreddyFlares,项目名称:SlidingBlock,代码行数:10,代码来源:SlidingBlockPuzzle.cs

示例6: Overlay

 public static Bitmap Overlay(IEnumerable<Bitmap> bmps, Bitmap.Config config = null)
 {
     int width = bmps.Max<Bitmap>(x => x.Width);
     int height = bmps.Max<Bitmap>(x => x.Height);
     Bitmap bmOverlay = Bitmap.CreateBitmap(width, height, config == null ? Bitmap.Config.Argb8888 : config);
     Canvas canvas = new Canvas(bmOverlay);
     foreach (var bmp in bmps)
         canvas.DrawBitmap(bmp, 0, 0, null);
     canvas.Dispose();
     return bmOverlay;
 }
开发者ID:kevincwq,项目名称:Cross.Drawing,代码行数:11,代码来源:BufferToBitmap.cs

示例7: SetPlotModelAxes

        public void SetPlotModelAxes(
            IEnumerable<DataPoint> seriesPoints,
            string xAxisTitle, string yAxisTitle)
        {
            double minXVal = seriesPoints.Min<DataPoint>(dp => dp.X);
            double maxXVal = seriesPoints.Max<DataPoint>(dp => dp.X);
            double minYVal = seriesPoints.Min<DataPoint>(dp => dp.Y);
            double maxYVal = seriesPoints.Max<DataPoint>(dp => dp.Y);

            PlotType = PlotType.XY;
            SetXAxisForPlotModel(minXVal, maxXVal, xAxisTitle);
            SetYAxisForPlotModel(minYVal, maxYVal, yAxisTitle);
        }
开发者ID:malcolmcarvalho,项目名称:TrimCurve,代码行数:13,代码来源:GreenFLOATOxyplotModel.cs

示例8: OctreeLookup

 public OctreeLookup(IEnumerable<float[]> points)
 {
     tree = new Octree(
         points.Max(p => p[0]),
         points.Min(p => p[0]),
         points.Max(p => p[1]),
         points.Min(p => p[1]),
         points.Max(p => p[2]),
         points.Min(p => p[2]),
         points.Count());
     foreach (var p in points)
         tree.AddNode(p[0], p[1], p[2], p);
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:13,代码来源:OctreeLookup.cs

示例9: ApplyChanges

        public void ApplyChanges(IEnumerable<Change> changeList)
        {
            // separate
            var speakerChanges = changeList.Where(c => string.Compare("speaker", c.EntityType, StringComparison.OrdinalIgnoreCase) == 0).ToList();
            var sessionChanges = changeList.Where(c => string.Compare("session", c.EntityType, StringComparison.OrdinalIgnoreCase) == 0).ToList();
            var updateClientChangeset = false;

            if (speakerChanges.Count > 0)
            {
                ApplySpeakerChanges(speakerChanges);
                SpeakerRepository.Save();
                updateClientChangeset = true;
            }

            if (sessionChanges.Count > 0)
            {
                ApplySessionChanges(sessionChanges);
                SessionRepository.Save();
                updateClientChangeset = true;
            }

            if (updateClientChangeset)
            {
                int changeSet = changeList.Max(c => c.Changeset);
                UpdateClientChangesetToLatest(changeSet);
            }
        }
开发者ID:xximjasonxx,项目名称:Codemash,代码行数:27,代码来源:CodemashChangeService.cs

示例10: AscendData

        public AscendData(IEnumerable<long> dataPoints, string planetName, bool failedAscends)
        {
            long highestPoint = dataPoints.Max();
            this._heightPoints = dataPoints.ToList();

            this._planetName = planetName;
            this._areFailedAscends = failedAscends;

            StringBuilder sb = new StringBuilder();
            sb = sb.Append("http://chart.apis.google.com/chart?").Append("cht=lc&chs=500x500")
                .Append("&chd=t:");

            foreach(double dataPoint in _heightPoints)
            {
                sb = sb.Append(dataPoint.ToString("0.00")).Append(',');
            }

            sb.Replace(',', '&', sb.Length - 1, 1);

            this._chartName = string.Format("{0} ascends from the planet {1}", this._areFailedAscends ? "Failed" : "Successful", this._planetName);

            sb = sb.Append("chtt=").Append(HttpUtility.UrlEncode(this._chartName)).Append("&hAxis.title=Height from surface");

            this._chartUrl = sb.ToString();

            log.DebugFormat("Created new AscendData, url is '{0}'", this._chartUrl);
        }
开发者ID:TheDutchDevil,项目名称:KerLog,代码行数:27,代码来源:AscendData.cs

示例11: ShowCommandUsage

        public void ShowCommandUsage(IEnumerable<Command> availableCommands, OptionSet optionSet)
        {
            var processName = Process.GetCurrentProcess().ProcessName;
            var usagePreamble = String.Format("Usage: {0} ", processName);
            var usagePattern = GenerateUsagePattern(optionSet);

            new ConsoleFormatter(ConsoleWriter.Default).Write(
                new ConsoleTable().AddRow(
                        new ConsoleCell(usagePreamble).WithWidth(usagePreamble.Length).WithPadding(0),
                        new ConsoleCell(usagePattern).WithPadding(0)));

            var maximumCommandNameLength = availableCommands.Count() > 0 ? availableCommands.Max(c => c.Name.Length) : 0;

            var commandTable = new ConsoleTable().
                AddEmptyRow().AddRow(
                    new ConsoleCell("The available commands are:").WithPadding(0));

            foreach (var command in availableCommands)
            {
                commandTable.AddRow(
                        new ConsoleCell(command.Name).WithWidth(maximumCommandNameLength),
                        new ConsoleCell(command.Description));
            }

            new ConsoleFormatter(ConsoleWriter.Default).Write(commandTable);
        }
开发者ID:surgicalcoder,项目名称:synoptic,代码行数:26,代码来源:HelpGenerator.cs

示例12: RefreshPlayerByList

 private void RefreshPlayerByList(IEnumerable<PlayerInfo> players)
 {
     foreach (var player in players.ToList())
     {
         var playerViewModel = Players.FirstOrDefault(p => p.Index == player.Index);
         if (playerViewModel == null)
         {
             Players.Add(new PlayersViewModel
             {
                 Index = player.Index,
                 Name = player.Name,
                 Duration = player.Duration,
             });
         }
         else
         {
             playerViewModel.Name = player.Name;
             playerViewModel.Score = player.Score;
             playerViewModel.Duration = player.Duration;
         }
     }
     var maxIndex = players.Any() ? players.Max(p => p.Index) : 0;
     var excessPlayers = Players.Where(ep => ep.Index > maxIndex);
     foreach (var excessPlayer in excessPlayers.ToList())
     {
         Players.Remove(excessPlayer);
     }
 }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:28,代码来源:ServerInfoViewModel.cs

示例13: Determine_col_widths

		int[] Determine_col_widths(IEnumerable<string[]> records) {
			var colWidths = new List<int> ();
			for (var i = 0; i < records.First ().Length; i++) {
				colWidths.Add (records.Max(r => r[i].Length));
			}
			return colWidths.ToArray ();
		}
开发者ID:ralfw,项目名称:ShellForms,代码行数:7,代码来源:Formatter.cs

示例14: RenderLegend

        protected override void RenderLegend(GraphPane gp, IEnumerable<RequestDataResults> dataResults)
        {
            var hostName = new TextObj(dataResults.First().HostName, dataResults.Count() + 1, dataResults.Max(x => x.AverageResponseTime) * 1.1);
            hostName.FontSpec.Fill.IsVisible = false;
            hostName.FontSpec.Border.IsVisible = false;
            hostName.FontSpec.FontColor = Color.Black;
            hostName.FontSpec.Size = 7;
            gp.GraphObjList.Add(hostName);

            var date = new TextObj(DateTime.Now.ToString(), dataResults.Count() + 1, dataResults.Max(x => x.AverageResponseTime) * 1.05);
            date.FontSpec.Fill.IsVisible = false;
            date.FontSpec.Border.IsVisible = false;
            date.FontSpec.FontColor = Color.Black;
            date.FontSpec.Size = 7;
            gp.GraphObjList.Add(date);
        }
开发者ID:fdore,项目名称:jmeter-toolkit,代码行数:16,代码来源:TrendChartBuilder.cs

示例15: Calculate

        public static VehicleStatisticsModel Calculate(IEnumerable<Model.FillupEntry> fillUps, bool includeFirst = true)
        {
            if (!fillUps.Any()) return new VehicleStatisticsModel();

            var firstFillUp = fillUps.OrderBy(x => x.Date).FirstOrDefault();

            double totalFuelCost = 0.0;
            double totalUnits = 0.0;
            double totalCost = 0.0;
            int totalDistance = 0;

            foreach (var fillUp in fillUps)
            {
                if (includeFirst || fillUp != firstFillUp)
                {
                    totalFuelCost += fillUp.PricePerUnit*fillUp.TotalUnits;
                    totalUnits += fillUp.TotalUnits;
                    totalCost += fillUp.TotalCost;
                    totalDistance += fillUp.Distance ?? 0;
                }
            }

            var odometer = fillUps.Max(x => x.Odometer);

            var earliestEntryDate = fillUps.Min(x => x.Date).ToUniversalTime();
            var today = DateTime.UtcNow.Date;
            var totalMonths = CalculateDifferenceInMonths(earliestEntryDate.Date, today.Date);

            return new VehicleStatisticsModel(totalFuelCost, totalUnits, totalCost, totalDistance, odometer, totalMonths);
        }
开发者ID:harimukkapati,项目名称:FootPrint,代码行数:30,代码来源:CalculateStatistics.cs


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