本文整理汇总了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;
}
示例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;
}
示例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;
}