当前位置: 首页>>代码示例>>C#>>正文


C# SortedSet.RemoveAll方法代码示例

本文整理汇总了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);
     }
       }
 }
开发者ID:RichardBradley,项目名称:regex-crossword,代码行数:34,代码来源:CharSet.cs

示例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;
        }
开发者ID:RichardBradley,项目名称:regex-crossword,代码行数:49,代码来源:CharSet.cs


注:本文中的SortedSet.RemoveAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。