本文整理汇总了C#中ISet.ToHashSet方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.ToHashSet方法的具体用法?C# ISet.ToHashSet怎么用?C# ISet.ToHashSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISet
的用法示例。
在下文中一共展示了ISet.ToHashSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindIndirectCircularReferences
private static void FindIndirectCircularReferences(ISet<Node> childList)
{
var toIgnore = new HashSet<Node>();
foreach (var node in childList.ToHashSet())
{
if(toIgnore.Contains(node))
continue;
var path = new HashSet<Node>();
if (IndirectlyDependsOnItself(node, node, ref path))
{
path.Add(node);
toIgnore.UnionWith(path);
childList.ExceptWith(path);
var dependantOnCircularDependencies = childList.Where(x => path.Any(x.DependsOn));
var cirularHolder = new CircularDependencyHolderNode(path);
foreach (var dependantOnCircularDependency in dependantOnCircularDependencies)
{
//Remove all dependencies on nodes in the path
dependantOnCircularDependency.SiblingDependencies.RemoveWhere(x => path.Contains(x));
//Add dependency on circular holder
dependantOnCircularDependency.SiblingDependencies.Add(cirularHolder);
}
//Add all dependencies in the path to the new node
cirularHolder.SiblingDependencies.UnionWith(path.SiblingDependencies().Except(path)); //Should not be dependant on themselves
childList.Add(cirularHolder);
}
}
}