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


C# IEnumerable.Min方法代码示例

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


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

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

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

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

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

示例6: MinDate

        public static DateTime MinDate(this IEnumerable<DateTime> left, IEnumerable<DateTime> right)
        {
            var minLeft = left.Any() ? left.Min() : DateTime.MaxValue;
            var minRight = right.Any() ? right.Min() : DateTime.MaxValue;

            return minLeft.Ticks < minRight.Ticks ? minLeft : minRight;
        }
开发者ID:techsavy,项目名称:AtYourService,代码行数:7,代码来源:DateTimeExtensions.cs

示例7: Normalize

        public static IEnumerable<double> Normalize(IEnumerable<double> collection)
        {
            double min = collection.Min();
            double max = collection.Max();

            return collection.Select(f => Normalize(f, min, max));
        }
开发者ID:GWigWam,项目名称:NeuralNet,代码行数:7,代码来源:MathHelper.cs

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

示例9: GetArea

        /// <summary>
        /// Gets area that's occupied by user selected points
        /// </summary>
        /// <param name="selector">Selected points container</param>
        /// <param name="maxWorkingArea">Minimum allowed area size</param>
        /// <returns></returns>
        public static System.Drawing.Rectangle GetArea(IEnumerable<PointSelector.SelectedPoint> selector, int workingAreaSize)
        {

            var minX = selector.Min(p => p.Location.X);
            var maxX = selector.Max(p => p.Location.X);
            var minY = selector.Min(p => p.Location.Y);
            var maxY = selector.Max(p => p.Location.Y);

            int areaWidth = maxX - minX;
            int areaHeight = maxY - minY;

            areaWidth = areaWidth > workingAreaSize ? workingAreaSize : areaWidth;
            areaWidth = areaHeight > workingAreaSize ? workingAreaSize : areaHeight;

            if (areaWidth < workingAreaSize)
            {
                minX = minX - (workingAreaSize - areaWidth) / 2;
                minX = minX < 0 ? 0 : minX;
                areaWidth = workingAreaSize;
            }

            if (areaHeight < workingAreaSize)
            {
                minY = minY - (workingAreaSize - areaHeight) / 2;
                minY = minY < 0 ? 0 : minY;
                areaHeight = workingAreaSize;
            }

            return new System.Drawing.Rectangle(minX, minY, areaWidth, areaHeight);
        }
开发者ID:worstward,项目名称:rlviewer,代码行数:36,代码来源:GeometryHelper.cs

示例10: Play

    public IEnumerable<Card> Play(IEnumerable<Card> hand, IEnumerable<Card> table, int rank, Suit suit, Mode mode, bool revolution, History history)
    {
        if (revolution && rank != Card.RankOfJoker)
        {
            rank = 14 - rank;
        }

        if (hand == null || hand.Count() == 0)
            return null;

        int count = table.Count();

        // 初手はとりあえず一番弱いのを出しとく。
        if (mode.Match(Mode.First))
        {
            var min = hand.Min(x => Game.Rank(x, revolution));
            return hand.Where(x => Game.Rank(x, revolution) == min);
        }

        if (mode.Match(Mode.Normal))
        {
            if(mode.Match(Mode.SuitBound))
            {
                return hand.MinCard(x => Game.Rank(x, revolution) > rank && x.Suit == suit, revolution);
            }
            else
            {
                return hand.MinCard(x => Game.Rank(x, revolution) > rank, revolution);
            }
        }

        if(mode.Match(Mode.Multiple))
        {
            for (int i = rank + 1; i <= 13; i++)
            {
                // 出せる
                var c = hand.Where(x => Game.Rank(x, revolution) == i);
                if (c.Count() >= count)
                    return c.Take(count);

                // Joker含めれば出せる
                if (c.Count() + 1 == count && hand.FirstOrDefault(x => x.Suit == Suit.Joker) != null)
                    return c.Concat(hand.Where(x => x.Suit == Suit.Joker).Take(count));
            }
        }

        if (mode.Match(Mode.SequenceBound))
            return null; //todo また未対応

        if (mode.Match(Mode.Sequence))
        {
            if (mode.Match(Mode.SuitBound))
                return hand.Sequence(rank, revolution, count, suit);
            else
                return hand.Sequence(rank, revolution, count);
        }

        return null;
    }
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:59,代码来源:shortsited.cs

示例11: ConvertToAst

        public List<ILNode> ConvertToAst(List<Instruction> body, IEnumerable<ExceptionHandler> ehs)
        {
            List<ILNode> ast = new List<ILNode>();

            while (ehs.Any()) {
                ILTryCatchBlock tryCatchBlock = new ILTryCatchBlock();

                // Find the first and widest scope
                int tryStart = ehs.Min(eh => eh.TryStart.Offset);
                int tryEnd   = ehs.Where(eh => eh.TryStart.Offset == tryStart).Max(eh => eh.TryEnd.Offset);
                var handlers = ehs.Where(eh => eh.TryStart.Offset == tryStart && eh.TryEnd.Offset == tryEnd).ToList();

                // Cut all instructions up to the try block
                {
                    int tryStartIdx;
                    for (tryStartIdx = 0; body[tryStartIdx].Offset != tryStart; tryStartIdx++);
                    ast.AddRange(ConvertToAst(body.CutRange(0, tryStartIdx)));
                }

                // Cut the try block
                {
                    List<ExceptionHandler> nestedEHs = ehs.Where(eh => (tryStart <= eh.TryStart.Offset && eh.TryEnd.Offset < tryEnd) || (tryStart < eh.TryStart.Offset && eh.TryEnd.Offset <= tryEnd)).ToList();
                    int tryEndIdx;
                    for (tryEndIdx = 0; tryEndIdx < body.Count && body[tryEndIdx].Offset != tryEnd; tryEndIdx++);
                    tryCatchBlock.TryBlock = ConvertToAst(body.CutRange(0, tryEndIdx), nestedEHs);
                }

                // Cut all handlers
                tryCatchBlock.CatchBlocks = new List<ILTryCatchBlock.CatchBlock>();
                foreach(ExceptionHandler eh in handlers) {
                    int start;
                    for (start = 0; body[start] != eh.HandlerStart; start++);
                    int end;
                    for (end = 0; body[end] != eh.HandlerEnd; end++);
                    int count = end - start;
                    List<ExceptionHandler> nestedEHs = ehs.Where(e => (start <= e.TryStart.Offset && e.TryEnd.Offset < end) || (start < e.TryStart.Offset && e.TryEnd.Offset <= end)).ToList();
                    List<ILNode> handlerAst = ConvertToAst(body.CutRange(start, count), nestedEHs);
                    if (eh.HandlerType == ExceptionHandlerType.Catch) {
                        tryCatchBlock.CatchBlocks.Add(new ILTryCatchBlock.CatchBlock() {
                            ExceptionType = eh.CatchType,
                            Body = handlerAst
                        });
                    } else if (eh.HandlerType == ExceptionHandlerType.Finally) {
                        tryCatchBlock.FinallyBlock = handlerAst;
                    } else {
                        // TODO
                    }
                }

                ehs = ehs.Where(eh => eh.TryStart.Offset > tryEnd).ToList();

                ast.Add(tryCatchBlock);
            }

            // Add whatever is left
            ast.AddRange(ConvertToAst(body));

            return ast;
        }
开发者ID:almazik,项目名称:ILSpy,代码行数:59,代码来源:ILAstBuilder.cs

示例12: GetTarget

        public override Character GetTarget(IEnumerable<Character> targetsList)
        {
            Character target = targetsList
                .Where(t => t.Team == this.Team && t.IsAlive == true && t.Id != this.Id)
                .FirstOrDefault(t => t.HealthPoints == targetsList.Min(h => h.HealthPoints));

            return target;
        }
开发者ID:nickgenov,项目名称:ObjectOrientedProgramming,代码行数:8,代码来源:Healer.cs

示例13: PerfIteratorResult

 public PerfIteratorResult(IEnumerable<PerfRoundResult> resultsList)
 {
     this.ResultsList = resultsList;
     this.RepeatCount = resultsList.Count();
     this.OverallAverageTicks = resultsList.Average(r => r.AverageTicks);
     this.OverallMaxTicks = resultsList.Max(r => r.MaxTicks);
     this.OverallMinTicks = resultsList.Min(r => r.MinTicks);
 }
开发者ID:LuanNunes,项目名称:MOO,代码行数:8,代码来源:PerfIteratorResult.cs

示例14: ConfigureParameters

    protected void ConfigureParameters(IEnumerable<double> data) {
      double originalRangeStart = data.Min();
      double originalRangeEnd = data.Max();

      double originalRangeWidth = originalRangeEnd - originalRangeStart;
      double targetRangeWidth = Range.End - Range.Start;

      Multiplier = targetRangeWidth / originalRangeWidth;
      Addend = Range.Start - originalRangeStart * Multiplier;
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:10,代码来源:ShiftToRangeTransformation.cs

示例15: FromPoints

        /// <summary>
        /// Creates a Polyline from a list of points and calculates the lines and bounds of the result
        /// </summary>
        /// <param name="points">The list of points that define the polyline</param>
        /// <returns>a Polyline object</returns>
        public static Polyline FromPoints(IEnumerable<Point> points)
        {
            Polyline poly = new Polyline();

            poly.Points = points.ToArray();
            if (poly.Points.Length > 1) {
                poly.Lines = new Line[poly.Points.Length - 1];
                for (int i = 0; i < poly.Lines.Length; i++) {
                    poly.Lines[i] = Line.FromPoints(
                        new Vector2(poly.Points[i].X, poly.Points[i].Y),
                        new Vector2(poly.Points[i + 1].X, poly.Points[i + 1].Y));
                }
            }

            poly.Bounds.X = points.Min(x => x.X);
            poly.Bounds.Y = points.Min(x => x.Y);
            poly.Bounds.Width = points.Max(x => x.X) - points.Min(x => x.X);
            poly.Bounds.Height = points.Max(x => x.Y) - points.Min(x => x.Y);

            return poly;
        }
开发者ID:jvlppm,项目名称:xtiled,代码行数:26,代码来源:Polyline.cs


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