本文整理汇总了C#中SortedSet.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.RemoveAll方法的具体用法?C# SortedSet.RemoveAll怎么用?C# SortedSet.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.RemoveAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Union
/// <summary>
/// Epands this charset as necessary so that the given CharSet is included in this one.
/// </summary>
/// <returns>this</returns>
public void Union(CharSet other)
{
if (IsInclusive)
{
if (other.IsInclusive)
{
// [AB] + [BC] = [ABC]
Chars.AddRange(other.Chars);
}
else
{
// [ABC] + [^CDE] = [^DE]
var previouslyIncluded = Chars;
Chars = new SortedSet<char>(other.Chars);
IsInclusive = false;
Chars.RemoveAll(previouslyIncluded);
}
}
else
{
if (other.IsInclusive)
{
Chars.RemoveAll(other.Chars);
}
else
{
Chars.IntersectWith(other.Chars);
}
}
}
示例2: Intersect
/// <summary>
/// Restricts this charset so that it is no more inclusive than the given one.
/// </summary>
/// <returns>
/// true if any changes were made
/// </returns>
/// <exception cref="EmptyIntersectionException">
/// if the intersection would be empty
/// </exception>
public bool Intersect(CharSet other)
{
bool changesMade;
if (IsInclusive)
{
if (other.IsInclusive)
{
var countBefore = Count;
Chars.IntersectWith(other.Chars);
changesMade = Count < countBefore;
}
else
{
changesMade = Chars.RemoveAll(other.Chars);
}
}
else
{
if (other.IsInclusive)
{
// [^AB] ^ [BC] = [C]
var previouslyExcluded = Chars;
Chars = new SortedSet<char>(other.Chars);
IsInclusive = true;
Chars.RemoveAll(previouslyExcluded);
changesMade = true;
}
else
{
changesMade = Chars.AddRange(other.Chars);
}
}
if (IsInclusive && Chars.Count == 0)
{
throw new EmptyIntersectionException("No chars were found in common");
}
return changesMade;
}