本文整理汇总了C#中System.Collections.Set.Union方法的典型用法代码示例。如果您正苦于以下问题:C# Set.Union方法的具体用法?C# Set.Union怎么用?C# Set.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Set
的用法示例。
在下文中一共展示了Set.Union方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSetUnion
public void TestSetUnion(Set<string> setFirst, Set<string> setSecond, Set<string> resultSet)
{
setFirst.Union(setSecond);
var iteratorFirst = setFirst.GetEnumerator();
var resultIterator = resultSet.GetEnumerator();
while (iteratorFirst.MoveNext() && resultIterator.MoveNext())
{
Assert.AreEqual(iteratorFirst.Current, resultIterator.Current);
}
}
示例2: GetAllProjects
/**
* returns a set of projects that a combine contains and a set of projects
* that are referenced from combine projects but not part of the combine
*/
void GetAllProjects (SolutionFolder folder, SolutionConfiguration config, out Set<SolutionFolderItem> projects, out Set<SolutionFolderItem> references)
{
List<SolutionFolderItem> subitems = new List<SolutionFolderItem> ();
GetSubItems (subitems, folder);
projects = (Set<SolutionFolderItem>) combineProjects [folder];
if (projects != null) {
references = (Set<SolutionFolderItem>) combineReferences [folder];
return;
}
projects = new Set<SolutionFolderItem>();
references = new Set<SolutionFolderItem>();
foreach (SolutionFolderItem item in subitems)
{
if (item is SolutionItem)
{
SolutionItem entry = (SolutionItem) item;
if (!config.BuildEnabledForItem (entry))
continue;
projects.Add (entry);
references.Union (entry.GetReferencedItems (config.Selector));
}
else if (item is SolutionFolder)
{
Set<SolutionFolderItem> subProjects;
Set<SolutionFolderItem> subReferences;
GetAllProjects ((SolutionFolder)item, config, out subProjects, out subReferences);
projects.Union (subProjects);
references.Union (subReferences);
}
}
references.Without (projects);
combineProjects [folder] = projects;
combineReferences [folder] = references;
}
示例3: CalculateSubDirOrder
// utility function for finding the correct order to process directories
List<SolutionFolderItem> CalculateSubDirOrder (AutotoolsContext ctx, SolutionFolder folder, SolutionConfiguration config)
{
List<SolutionFolderItem> resultOrder = new List<SolutionFolderItem>();
Set<SolutionFolderItem> dependenciesMet = new Set<SolutionFolderItem>();
Set<SolutionFolderItem> inResult = new Set<SolutionFolderItem>();
// We don't have to worry about projects built in parent combines
dependenciesMet.Union (ctx.GetBuiltProjects ());
bool added;
string notMet;
do
{
added = false;
notMet = null;
List<SolutionFolderItem> items = new List<SolutionFolderItem> ();
GetSubItems (items, folder);
foreach (SolutionFolderItem item in items)
{
Set<SolutionFolderItem> references, provides;
if (inResult.Contains (item))
continue;
if (item is SolutionItem)
{
SolutionItem entry = (SolutionItem) item;
if (!config.BuildEnabledForItem (entry))
continue;
references = new Set<SolutionFolderItem> ();
provides = new Set<SolutionFolderItem>();
references.Union (entry.GetReferencedItems (config.Selector));
provides.Add (entry);
}
else if (item is SolutionFolder) {
GetAllProjects ((SolutionFolder) item, config, out provides, out references);
}
else
continue;
if (dependenciesMet.ContainsSet (references) )
{
resultOrder.Add (item);
dependenciesMet.Union(provides);
inResult.Add(item);
added = true;
}
else notMet = item.Name;
}
} while (added);
if (notMet != null)
throw new Exception("Impossible to find a solution order that satisfies project references for '" + notMet + "'");
return resultOrder;
}
示例4: Union
/// <summary>
/// Performs a "union" of two sets, where all the elements
/// in both are present. That is, the element is included if it is in either <c>a</c> or <c>b</c>.
/// The return value is a <c>Clone()</c> of one of the sets (<c>a</c> if it is not <c>null</c>) with elements of the other set
/// added in. Neither of the input sets is modified by the operation.
/// </summary>
/// <param name="a">A set of elements.</param>
/// <param name="b">A set of elements.</param>
/// <returns>A set containing the union of the input sets. <c>null</c> if both sets are <c>null</c>.</returns>
public static Set Union(Set a, Set b)
{
if (a == null && b == null)
return null;
else if(a == null)
return (Set)b.Clone();
else if(b == null)
return (Set)a.Clone();
else
return a.Union(b);
}