本文整理汇总了C#中Bag.Size方法的典型用法代码示例。如果您正苦于以下问题:C# Bag.Size方法的具体用法?C# Bag.Size怎么用?C# Bag.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bag
的用法示例。
在下文中一共展示了Bag.Size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
const string fieName = "tobe.txt";
var @in = new In($"Files\\Collections\\{fieName}");
var words = @in.ReadAllStrings();
var bag = new Bag<string>();
foreach (var word in words)
{
bag.Add(word);
}
Console.WriteLine("size of bag = {0}", bag.Size());
foreach (var item in bag)
{
Console.WriteLine("item = {0}", item);
}
Console.ReadLine();
}
示例2: LoadEntityState
public void LoadEntityState(String tag,String groupName,Bag<Component> components)
{
Entity e;
if(tag != null) {
e = CreateEntity(tag);
} else {
e = CreateEntity();
}
if(groupName != null) {
groupManager.Set(groupName,e);
}
for(int i = 0, j = components.Size(); i < j; i++) {
e.AddComponent(components.Get(i));
}
}
示例3: Recognizes
/// <summary>
/// Does the NFA recognize txt?
/// Returns true if the text is matched by the regular expression.
/// </summary>
/// <param name="txt">txt the text</param>
/// <returns><tt>true</tt> if the text is matched by the regular expression, <tt>false</tt> otherwise</returns>
public bool Recognizes(string txt)
{
var dfs = new DirectedDFS(_g, 0);
var pc = new Bag<Integer>();
for (var v = 0; v < _g.V; v++)
if (dfs.Marked(v)) pc.Add(v);
// Compute possible NFA states for txt[i+1]
for (var i = 0; i < txt.Length; i++)
{
var match = new Bag<Integer>();
foreach (int v in pc)
{
if (v == _m) continue;
if ((_regexp[v] == txt[i]) || _regexp[v] == '.')
match.Add(v + 1);
}
dfs = new DirectedDFS(_g, match);
pc = new Bag<Integer>();
for (var v = 0; v < _g.V; v++)
if (dfs.Marked(v)) pc.Add(v);
// optimization if no states reachable
if (pc.Size() == 0) return false;
}
// check for accept state
foreach (int v in pc)
if (v == _m) return true;
return false;
}