本文整理汇总了C#中SortedSet.ExceptWith方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.ExceptWith方法的具体用法?C# SortedSet.ExceptWith怎么用?C# SortedSet.ExceptWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.ExceptWith方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AprioriGen
//产生候选集:使用《数据挖掘导论》上P210页的方法
static List<SortedSet<string>> AprioriGen(List<SortedSet<string>> kFequentSet)
{
List<SortedSet<string>> result = new List<SortedSet<string>>();
for (int i = 0; i < kFequentSet.Count; i++)
{
SortedSet<string> aTmpSet = new SortedSet<string>(kFequentSet[i]);
string aLastElement = kFequentSet[i].Last<string>();
aTmpSet.Remove(aLastElement);//去掉最后一个元素
for (int j = i + 1; j < kFequentSet.Count; j++)
{
SortedSet<string> bTmpSet = new SortedSet<string>(kFequentSet[j]);
string bLastElement = kFequentSet[j].Last<string>();
bTmpSet.Remove(bLastElement);//去掉最后一个元素
if (bTmpSet.Count == aTmpSet.Count)
{
bTmpSet.ExceptWith(aTmpSet);
if (bTmpSet.Count == 0 && !aLastElement.Equals(bLastElement))//前k-2个元素相同而最后一个元素不同
{
result.Add(new SortedSet<string>(kFequentSet[i]));
result[result.Count - 1].Add(bLastElement);
}
}
}
}
return result;
}
示例2: CalculateDominatesSet
public static SortedSet<IRBlock> CalculateDominatesSet(IRGraph cfg, SortedSet<IRBlock> V, SortedSet<IRBlock> VSansR, IRBlock v)
{
SortedSet<IRBlock> VSansv = new SortedSet<IRBlock>();
VSansv.UnionWith(V);
VSansv.Remove(v); // V - {v}
SortedSet<IRBlock> S = FindReachableBlocks(cfg, v.GetIndex());
VSansv.ExceptWith(S);
return VSansv; // V - {v} - S
}
示例3: ExcludeLeft
static SortedSet<char> ExcludeLeft(SortedSet<char> intersectionResult,
string[] tokens)
{
char[] rightArray = tokens[1].ToCharArray();
SortedSet<char> result =
new SortedSet<char>();
result.UnionWith(rightArray);
result.ExceptWith(intersectionResult);
return result;
}
示例4: Main
static void Main()
{
var companyTeams = new HashSet<string>() { "Ferrari", "McLaren", "Mercedes" };
var traditionalTeams = new HashSet<string>() { "Ferrari", "McLaren" };
var privateTeams = new HashSet<string>() { "Red Bull", "Lotus", "Toro Rosso", "Force India", "Sauber" };
if (privateTeams.Add("Williams"))
WriteLine("Williams added");
if (!companyTeams.Add("McLaren"))
WriteLine("McLaren was already in this set");
if (traditionalTeams.IsSubsetOf(companyTeams))
{
WriteLine("traditionalTeams is subset of companyTeams");
}
if (companyTeams.IsSupersetOf(traditionalTeams))
{
WriteLine("companyTeams is a superset of traditionalTeams");
}
traditionalTeams.Add("Williams");
if (privateTeams.Overlaps(traditionalTeams))
{
WriteLine("At least one team is the same with traditional and private teams");
}
var allTeams = new SortedSet<string>(companyTeams);
allTeams.UnionWith(privateTeams);
allTeams.UnionWith(traditionalTeams);
WriteLine();
WriteLine("all teams");
foreach (var team in allTeams)
{
WriteLine(team);
}
allTeams.ExceptWith(privateTeams);
WriteLine();
WriteLine("no private team left");
foreach (var team in allTeams)
{
WriteLine(team);
}
}
示例5: ShowExcess
static void ShowExcess(string dir, SortedSet<string> keepFiles, bool deleteExcess)
{
var allFiles = Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories);
if (Path.AltDirectorySeparatorChar != Path.DirectorySeparatorChar)
allFiles = allFiles.Select(s => s.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
var toDel = new SortedSet<string>(allFiles);
toDel.ExceptWith(keepFiles);
if (toDel.Count > 0)
Console.WriteLine("Excess files:");
foreach (var f in toDel)
if (deleteExcess)
{
Console.Write(f);
File.Delete(f);
Console.WriteLine(" removed.");
}
else
Console.WriteLine(f);
// TODO: Remove empty dirs.
if (toDel.Count > 0 && deleteExcess)
Console.WriteLine("Done.");
}
示例6: CreateSmallestDependencyCollection
public static SortedSet<byte[]> CreateSmallestDependencyCollection(ChunkRepository repo, SortedSet<byte[]> chunks, int extraPasses = 4)
{
SortedSet<byte[]> removables = new SortedSet<byte[]> (ByteSequenceComparer.Shared);
SortedSet<byte[]> resolved = new SortedSet<byte[]> (chunks, ByteSequenceComparer.Shared);
SortedSet<byte[]> results = new SortedSet<byte[]> (chunks, ByteSequenceComparer.Shared);
foreach (byte[] chunk in chunks) {
removables.UnionWith (repo.ldataDependencies.Get (chunk));
}
for (int n = 0; n != extraPasses; n++) {
foreach (byte[] chunk in removables) {
if (!resolved.Contains (chunk)) {
removables.UnionWith (repo.ldataDependencies.Get (chunk));
resolved.Add (chunk);
}
}
}
results.ExceptWith (removables);
return results;
}
示例7: WrapUpSnippetCode
private void WrapUpSnippetCode(CodeSnippet codeSnippet, string commentLine)
{
// If the commentLine is empty, then all the snippet should be inserted (default: all bold)
if (commentLine != string.Empty)
{
var linesToMark = new SortedSet<int>();
var strikedLines = new SortedSet<int>();
// These are the lines that are bolded
linesToMark = this.GetLinesFromCommand(commentLine, "mark");
try
{
// These are the lines that are strikethrough
strikedLines = this.GetLinesFromCommand(commentLine, "strike");
}
catch (Exception)
{
strikedLines = null;
}
if (strikedLines != null)
{
// remove the strikedthrough lines from the list
linesToMark.ExceptWith(strikedLines.ToList());
}
codeSnippet.Code = this.RemoveExtraLines(linesToMark, codeSnippet.Code);
}
}
示例8: LoadXmlDictionary
// This method should never allow any exceptions to escape.
private void LoadXmlDictionary(XDocument dictionary)
{
try
{
// I am sure that a more clever linq expression is possible here.
IEnumerable<string> words = null;
var recognizedElement = dictionary.Descendants("Recognized").FirstOrDefault();
if (recognizedElement != null)
words = from w in recognizedElement.Descendants("Word") where !String.IsNullOrEmpty(w.Value) select w.Value;
// We have no valid dictionary, so don't change anything.
if (words == null) return;
var newWords = new SortedSet<string>(words);
// Get a copy of the ignore words
var ignorewords = _projectDictionaryWords;
// Replace the ignorewords with our new words. Not sure if the lock is necessary??
lock (_projectDictionaryWords)
_projectDictionaryWords = newWords;
// If we get to here, we have successfully loaded a dictionary.
// Now figure out the added words.
var exceptionWords = new SortedSet<string>(newWords);
exceptionWords.ExceptWith(ignorewords);
// Added words.
foreach (var w in exceptionWords)
RaiseSpellingChangedEvent(w);
// Figure out the deleted words.
ignorewords.ExceptWith(newWords);
// If any words are deleted, all text must be dirtied and rechecked
if (ignorewords.Count > 0)
RaiseSpellingChangedEvent(null);
}
catch (Exception)
{
// Do nothing, do not update the ignore words.
}
}