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


C# Set.Where方法代码示例

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


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

示例1: GetObstaclesFromPassport

        Set<Shape> GetObstaclesFromPassport(Set<Shape> passport) {
            if (passport.Count == 0)
                return new Set<Shape>(root.Children);
            var commonAncestors = GetCommonAncestorsAbovePassport(passport);
            var allAncestors = GetAllAncestors(passport);
            var ret = new Set<Shape>(passport.SelectMany(p => p.Children.Where(child => !allAncestors.Contains(child))));
            var enqueued = new Set<Shape>(passport.Concat(ret));
            var queue = new Queue<Shape>();
            foreach (var shape in passport.Where(shape => !commonAncestors.Contains(shape)))
                queue.Enqueue(shape);

            while (queue.Count > 0) {
                var a = queue.Dequeue();
                foreach (var parent in a.Parents) {
                    foreach (var sibling in parent.Children)
                        if (!allAncestors.Contains(sibling))
                            ret.Insert(sibling);

                    if (!commonAncestors.Contains(parent) && !enqueued.Contains(parent)) {
                        queue.Enqueue(parent);
                        enqueued.Insert(parent);
                    }
                }
            }
            return ret;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:26,代码来源:SplineRouter.cs

示例2: TrimModifiedAnnotationSet

		/// <summary>
		/// Trim down set of AnalysisReference objects to only those referencing segments that are
		/// modified. (We aren't deleting them, just narrowing down the ones to possibly update.)
		/// NB.: Use this BEFORE modifying the old Segments on the paragraph!
		/// </summary>
		/// <param name="annObjectsToCheck"></param>
		/// <returns></returns>
		private Set<IAnalysisReference> TrimModifiedAnnotationSet(Set<IAnalysisReference> annObjectsToCheck)
		{
			if (annObjectsToCheck == null)
				return null; // none to remove.
			List<IAnalysisReference> result;
			result = annObjectsToCheck.Where(SegmentIsOutsideOfRange).ToList();
			if (result.Count > 0)
				foreach (var iar in result)
					annObjectsToCheck.Remove(iar);
			return annObjectsToCheck;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:18,代码来源:AnalysisAdjuster.cs

示例3: TryInsertingNodesAndRoutes

        internal int TryInsertingNodesAndRoutes(int numNodesToInsert,
            Dictionary<SymmetricTuple<LgNodeInfo>, List<Point>> trajectories,
            List<SymmetricSegment> oldSegments,  
            int zoomLevel, int numNodesOnPreviousLevel,
            GridTraversal grid, LgPathRouter pathRouter)
        {
            MarkAllNodesNotProcessed();
            _segmentTileTable = new Dictionary<Tuple<int, int>, int>();
            _nodeTileTable = new Dictionary<Tuple<int, int>, int>();

            var canAddOldSegments = TryAddingOldSegments(oldSegments, grid);
            if (!canAddOldSegments)
            {
                return 0;
            }

            AddOldNodes(numNodesOnPreviousLevel, grid);

            int i;
            for (i = numNodesOnPreviousLevel; i < numNodesToInsert; i++)
            {
                var ni = SortedLgNodeInfos[i];
                var nodeTile = grid.PointToTuple(ni.Center);
                if (!_nodeTileTable.ContainsKey(nodeTile))
                    _nodeTileTable[nodeTile] = 0;

                if (_nodeTileTable[nodeTile] >= MaxNodesPerTile(zoomLevel)) //test MaxAmountNodesPerTile
                {
                    ShowDebugInsertedSegments(grid, zoomLevel, ni, null, null);

                    break;
                }

                Set<VisibilityEdge> edges = GetSegmentsOnPathsToInsertedNeighborsNotOnOldTrajectories(ni, trajectories,
                    pathRouter);

                Set<SymmetricSegment> segments = new Set<SymmetricSegment>(
                    edges.Select(e => new SymmetricSegment(e.SourcePoint, e.TargetPoint)));

                var newToAdd = segments.Where(seg => !IsSegmentAlreadyAdded(seg)).ToList();

                Set<SymmetricSegment> insertedSegments;
                bool canInsertPaths = TryAddingSegmentsUpdateTiles(newToAdd, grid, out insertedSegments);

                if (canInsertPaths) {

                    AddSegmentsToRtree(newToAdd);
                    ni.Processed = true;
                    _nodeTileTable[nodeTile]++;
                    _insertedNodes.Add(ni);
                    continue;
                }
                //debug output
                //AddSegmentsToRtree(newToAdd);   //remove
            //    ShowDebugInsertedSegments(grid, zoomLevel, ni, newToAdd, segments);
                break;
            }

            var nextNode = numNodesToInsert < SortedLgNodeInfos.Count ? SortedLgNodeInfos[numNodesToInsert] :
            null;
           // ShowDebugInsertedSegments(grid, zoomLevel, nextNode, null, null);

            return i;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:64,代码来源:GreedyNodeRailLevelCalculator.cs


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