本文整理汇总了C#中StringSet.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# StringSet.Remove方法的具体用法?C# StringSet.Remove怎么用?C# StringSet.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet.Remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldRemoveAndContainsReturnFalse
public void ShouldRemoveAndContainsReturnFalse()
{
var stringSet = new StringSet();
stringSet.Add("Test");
Assert.IsTrue(stringSet.Contains("Test"));
stringSet.Remove("Test");
Assert.IsFalse(stringSet.Contains("Test"));
}
示例2: 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);
}
示例3: 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"]);
}
示例4: FilterBracesInExpectedSet
private StringSet FilterBracesInExpectedSet(StringSet stateExpectedSet) {
var result = new StringSet();
result.UnionWith(stateExpectedSet);
//Find what brace we expect
var nextClosingBrace = string.Empty;
if (OpenBraces.Count > 0) {
var lastOpenBraceTerm = OpenBraces.Peek().KeyTerm;
var nextClosingBraceTerm = lastOpenBraceTerm.IsPairFor as KeyTerm;
if (nextClosingBraceTerm != null)
nextClosingBrace = nextClosingBraceTerm.Text;
}
//Now check all closing braces in result set, and leave only nextClosingBrace
foreach(var closingBrace in Language.GrammarData.ClosingBraces) {
if (result.Contains(closingBrace) && closingBrace != nextClosingBrace)
result.Remove(closingBrace);
}
return result;
}
示例5: GetCurrentExpectedSymbols
private StringList GetCurrentExpectedSymbols()
{
BnfTermList inputElements = new BnfTermList();
StringSet inputKeys = new StringSet();
inputKeys.AddRange(_currentState.Actions.Keys);
//First check all NonTerminals
foreach (NonTerminal nt in Data.NonTerminals) {
if (!inputKeys.Contains(nt.Key)) continue;
//nt is one of our available inputs; check if it has an alias. If not, don't add it to element list;
// and we have already all its "Firsts" keys in the list.
// If yes, add nt to element list and remove
// all its "fists" symbols from the list. These removed symbols will be represented by single nt alias.
if (string.IsNullOrEmpty(nt.DisplayName))
inputKeys.Remove(nt.Key);
else {
inputElements.Add(nt);
foreach(string first in nt.Firsts)
inputKeys.Remove(first);
}
}
//Now terminals
foreach (Terminal term in Data.Terminals) {
if (inputKeys.Contains(term.Key))
inputElements.Add(term);
}
StringList result = new StringList();
foreach(BnfTerm term in inputElements)
result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName);
result.Sort();
return result;
}