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


C# StringSet类代码示例

本文整理汇总了C#中StringSet的典型用法代码示例。如果您正苦于以下问题:C# StringSet类的具体用法?C# StringSet怎么用?C# StringSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Empty

 public void Empty()
 {
     StringSet ss = new StringSet(new string[] { "" });
     Assert.AreEqual(1, ss.Count);
     ss = new StringSet((string[])null);
     Assert.AreEqual(0, ss.Count);
 }
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:7,代码来源:StringSet.cs

示例2: Enumerate

        public void Enumerate()
        {
            StringSet ss = new StringSet();

            int i = 0;
            foreach (string s in ss)
            {
                i++;
                Console.WriteLine(s);
            }
            Assert.AreEqual(0, i);

            ss.Add("bloo");
            ss.Add("foo");
            ss.Add("bar");
            foreach (string s in ss)
            {
                i++;
                Console.WriteLine(s);
            }
            Assert.AreEqual(3, i);
            string[] arr = ss.GetStrings();
            Array.Sort(arr);
            Assert.AreEqual("bar", arr[0]);
            Assert.AreEqual("bloo", arr[1]);
            Assert.AreEqual("foo", arr[2]);
            Assert.AreEqual(3, arr.Length);
        }
开发者ID:krbysn,项目名称:jabber-net,代码行数:28,代码来源:StringSet.cs

示例3: ShouldRemoveAndContainsReturnFalse

 public void ShouldRemoveAndContainsReturnFalse()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     Assert.IsTrue(stringSet.Contains("Test"));
     stringSet.Remove("Test");
     Assert.IsFalse(stringSet.Contains("Test"));
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:8,代码来源:StringSetTest.cs

示例4: ShouldCount

 public void ShouldCount()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     Assert.AreEqual(3, stringSet.Count);
     
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:9,代码来源:StringSetTest.cs

示例5: ShouldClearTheSet

 public void ShouldClearTheSet()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Clear();
     Assert.AreEqual(0, stringSet.Count);
     
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:10,代码来源:StringSetTest.cs

示例6: ShouldEnumerate

 public void ShouldEnumerate()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     foreach (var test in stringSet)
     {
         Assert.IsTrue(stringSet.Contains(test));
     }
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:11,代码来源:StringSetTest.cs

示例7: ShouldUnionTwoSet

        public void ShouldUnionTwoSet()
        {
            var set1 = new StringSet();
            var set2 = new StringSet();
            set1.Add("Test1");
            set2.Add("Test2");


            StringSet union = set1.Union(set2);

            Assert.AreEqual(2, union.Count);

            Assert.IsTrue( union.Contains("Test1"));
            Assert.IsTrue( union.Contains("Test2"));
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:15,代码来源:StringSetTest.cs

示例8: Add

        public void Add()
        {
            StringSet ss = new StringSet();
            ss.Add("foo");
            ss.Add("foo");
            ss.Add("bar");
            Assert.IsTrue(ss["foo"]);
            Assert.AreEqual(2, ss.Count);
            Assert.AreEqual("foo\r\nbar\r\n", ss.ToString());
            ss.Remove("bar");
            Assert.AreEqual(1, ss.Count);
            Assert.IsFalse(ss["fool"]);

            ss = new StringSet(new string[] { "foo", "bar"});
            ss.Add(new StringSet("baz"));
            Assert.AreEqual(3, ss.Count);
        }
开发者ID:krbysn,项目名称:jabber-net,代码行数:17,代码来源:StringSet.cs

示例9: ShouldIntersect

        public void ShouldIntersect()
        {
            var set1 = new StringSet();
            var set2 = new StringSet();
            set1.Add("Test1");
            set1.Add("Common1");
            set1.Add("Common2");
            set2.Add("Common1");
            set2.Add("Common2");
            set2.Add("Test2");


            StringSet intersect = set1.Intersect(set2);

            Assert.AreEqual(2, intersect.Count);

            Assert.IsTrue(intersect.Contains("Common1"));
            Assert.IsTrue(intersect.Contains("Common2"));
            
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:20,代码来源:StringSetTest.cs

示例10: ComputeGroupedExpectedSetForState

 internal static StringSet ComputeGroupedExpectedSetForState(Grammar grammar, ParserState state)
 {
     var terms = new TerminalSet();
       terms.UnionWith(state.ExpectedTerminals);
       var result = new StringSet();
       //Eliminate no-report terminals
       foreach(var group in grammar.TermReportGroups)
     if (group.GroupType == TermReportGroupType.DoNotReport)
     terms.ExceptWith(group.Terminals);
       //Add normal and operator groups
       foreach(var group in grammar.TermReportGroups)
     if((group.GroupType == TermReportGroupType.Normal || group.GroupType == TermReportGroupType.Operator) &&
      terms.Overlaps(group.Terminals)) {
       result.Add(group.Alias);
       terms.ExceptWith(group.Terminals);
     }
       //Add remaining terminals "as is"
       foreach(var terminal in terms)
     result.Add(terminal.ErrorAlias);
       return result;
 }
开发者ID:guillaume86,项目名称:vsLua,代码行数:21,代码来源:CoreParser_ErrorHandling.cs

示例11: Merge

        public void Merge()
        {
            StringSet ss = new StringSet();
            ss.Add("foo");
            StringSet so = new StringSet();
            so.Add("bar");
            so.Add("baz");
            ss.Add(so);
            Assert.AreEqual(3, ss.Count);

            so = new StringSet();
            so.Add("boo");
            so.Add("baz");
            ss.Add(so);
            Assert.AreEqual(4, ss.Count);

            ss.Remove(so);
            Assert.AreEqual(2, ss.Count);
            Assert.IsTrue(ss["foo"]);
            Assert.IsTrue(ss["bar"]);
            Assert.IsFalse(ss["boo"]);
            Assert.IsFalse(ss["baz"]);
            Assert.IsFalse(ss["bloo"]);
        }
开发者ID:krbysn,项目名称:jabber-net,代码行数:24,代码来源:StringSet.cs

示例12: ShouldAddStringAndContainsReturnTrue

 public void ShouldAddStringAndContainsReturnTrue()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     Assert.IsTrue(stringSet.Contains("Test"));
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:6,代码来源:StringSetTest.cs

示例13: ValidateAll

 private void ValidateAll()
 {
   StringSet ntList = new StringSet();
   foreach (NonTerminal nt in _data.NonTerminals)
   {
     if (nt == _data.AugmentedRoot) continue;
     BnfExpressionData data = nt.Rule.Data;
     if (data.Count == 1 && data[0].Count == 1 && data[0][0] is NonTerminal)
       ntList.Add(nt.Name);
   }
   if (ntList.Count > 0)
   {
     AddError("Warning: Possible non-terminal duplication. The following non-terminals have rules containing a single non-terminal: \r\n {0}. \r\n" +
      "Consider merging two non-terminals; you may need to use 'nt1 = nt2;' instead of 'nt1.Rule=nt2'.");
   }
 }
开发者ID:eightrivers,项目名称:SSharp,代码行数:16,代码来源:GrammarDataBuilder.cs

示例14: CalculateTailFirsts

    private void CalculateTailFirsts()
    {
      foreach (Production prod in _data.Productions)
      {
        StringSet accumulatedFirsts = new StringSet();
        bool allNullable = true;

        for (int i = prod.LR0Items.Count - 1; i >= 0; i--)
        {
          LR0Item item = prod.LR0Items[i];
          if (i >= prod.LR0Items.Count - 2)
          {
            item.TailIsNullable = true;
            item.TailFirsts.Clear();
            continue;
          }
          GrammarTerm term = prod.RValues[item.Position + 1]; 
          NonTerminal ntElem = term as NonTerminal;
          if (ntElem == null || !ntElem.Nullable)
          { 
            accumulatedFirsts.Clear();
            allNullable = false;
            item.TailIsNullable = false;
            if (ntElem == null)
            {
              item.TailFirsts.Add(term.Key);
              accumulatedFirsts.Add(term.Key);
            }
            else
            {
              item.TailFirsts.AddRange(ntElem.Firsts); 
              accumulatedFirsts.AddRange(ntElem.Firsts);
            }
            continue;
          }
          accumulatedFirsts.AddRange(ntElem.Firsts);
          item.TailFirsts.AddRange(accumulatedFirsts);
          item.TailIsNullable = allNullable;
        }
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:41,代码来源:GrammarDataBuilder.cs

示例15: Create

 public void Create()
 {
     StringSet ss = new StringSet();
     Assert.AreEqual(0, ss.Count);
     Assert.AreEqual("", ss.ToString());
 }
开发者ID:krbysn,项目名称:jabber-net,代码行数:6,代码来源:StringSet.cs


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