本文整理汇总了C#中StringSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StringSet.Add方法的具体用法?C# StringSet.Add怎么用?C# StringSet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: ShouldCount
public void ShouldCount()
{
var stringSet = new StringSet();
stringSet.Add("Test");
stringSet.Add("Test");
stringSet.Add("Test");
Assert.AreEqual(3, stringSet.Count);
}
示例3: ShouldClearTheSet
public void ShouldClearTheSet()
{
var stringSet = new StringSet();
stringSet.Add("Test");
stringSet.Add("Test");
stringSet.Add("Test");
stringSet.Clear();
Assert.AreEqual(0, stringSet.Count);
}
示例4: 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));
}
}
示例5: ShouldRemoveAndContainsReturnFalse
public void ShouldRemoveAndContainsReturnFalse()
{
var stringSet = new StringSet();
stringSet.Add("Test");
Assert.IsTrue(stringSet.Contains("Test"));
stringSet.Remove("Test");
Assert.IsFalse(stringSet.Contains("Test"));
}
示例6: 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);
}
示例7: 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"));
}
示例8: 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;
}
示例9: 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"]);
}
示例10: 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"));
}
示例11: Null
public void Null()
{
StringSet ss = new StringSet();
ss.Add((string)null);
}
示例12: LoadStringSet
private static void LoadStringSet(StringSet set, XmlReader reader)
{
reader.ReadStartElement(PROPERTY_ID);
while (reader.IsStartElement(ITEM_ID))
{
string item;
bool isEmptyItem;
isEmptyItem = reader.IsEmptyElement;
reader.ReadStartElement();
item = reader.ReadString();
set.Add(item);
if (!isEmptyItem) reader.ReadEndElement();
}
}
示例13: ShouldAddStringAndContainsReturnTrue
public void ShouldAddStringAndContainsReturnTrue()
{
var stringSet = new StringSet();
stringSet.Add("Test");
Assert.IsTrue(stringSet.Contains("Test"));
}
示例14: CheckAliases
protected void CheckAliases(TranslationContext context, IEnumerable<Expression> outExpressions)
{
var sqlExpressions = outExpressions.OfType<SqlExpression>().ToList();
var allNames = new StringSet();
foreach(var outExpr in sqlExpressions) {
string outName = null;
var col = outExpr as ColumnExpression;
if (col != null) {
//if (isView) col.Alias = col.Name;
outName = col.Alias ?? col.Name;
}
var needsAlias = outName != null && allNames.Contains(outName);
if(outName != null)
allNames.Add(outName);
if(needsAlias)
outExpr.Alias = CreateDefaultAlias(outExpr, allNames);
}//foreach outExpr
}
示例15: BuildApprovedFunctionsStringSet
private static StringSet BuildApprovedFunctionsStringSet()
{
var result = new StringSet();
result.Add("_TlgWrite");
return result;
}