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


C# CharSetSolver.ComputeDomainSize方法代码示例

本文整理汇总了C#中CharSetSolver.ComputeDomainSize方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.ComputeDomainSize方法的具体用法?C# CharSetSolver.ComputeDomainSize怎么用?C# CharSetSolver.ComputeDomainSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CharSetSolver的用法示例。


在下文中一共展示了CharSetSolver.ComputeDomainSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSurrogateRange

 public void TestSurrogateRange()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     //high and low surrogate pair elements
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\p{Cs}");
     cond.ToDot("surr.dot");
     int elems = (int)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(7, nodes); //highly compact BDD representation
     var ranges = solver.ToRanges(cond);
     Assert.AreEqual<int>(1, ranges.Length);
     Assert.AreEqual<uint>(ranges[0].First, 0xd800);
     Assert.AreEqual<uint>(ranges[0].Second, 0xdFFF);
     //the total number of surrogates (there are 1024 low surrogates and 1024 high surrogates)
     Assert.AreEqual<int>(2048, elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:16,代码来源:CharSetTests.cs

示例2: TestLargeRange2

 public void TestLargeRange2()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF\uA000-\uA00F]");
     uint elems = (uint)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(14, nodes);
     var ranges = solver.ToRanges(cond);
     Assert.AreEqual<int>(2, ranges.Length);
     Assert.AreEqual<uint>(ranges[0].First, 0);
     Assert.AreEqual<uint>(ranges[0].Second, 0x7FFF);
     Assert.AreEqual<uint>(ranges[1].First, 0xA000);
     Assert.AreEqual<uint>(ranges[1].Second, 0xA00F);
     Assert.AreEqual<uint>(((uint)1 << 15) + ((uint)1 << 4), elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:15,代码来源:CharSetTests.cs

示例3: TestLargeRange

 public void TestLargeRange()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF]");
     int elems = (int)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(3, nodes);
     Assert.AreEqual<int>((1 << 15), elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:9,代码来源:CharSetTests.cs

示例4: TestDotGen

 public void TestDotGen()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV7);
     BDD cond = solver.MkCharSetFromRange('\0', '\x0F');
     int cnt = (int)solver.ComputeDomainSize(cond);
     cond.ToDot(@"bdd2.dot");
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:7,代码来源:CharSetTests.cs

示例5: TestCardinality3

 public void TestCardinality3()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\w-[\d]]");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int wCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         int cat = (int)char.GetUnicodeCategory((char)i);
         if (cat == 0 || cat == 1 || cat == 2 || cat == 3 || cat == 4 || cat == 5 ||
              cat == 8 || cat == 18) //same as \w in regex
             if (!char.IsDigit((char)i))
                 wCnt += 1;
     }
     Assert.AreEqual<int>(wCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:24,代码来源:CharSetTests.cs

示例6: TestCardinality

 public void TestCardinality()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int digitCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         if (char.IsDigit(((char)i)))
             digitCnt += 1;
     }
     Assert.AreEqual<int>(digitCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:21,代码来源:CharSetTests.cs


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