本文整理汇总了C#中ST.Size方法的典型用法代码示例。如果您正苦于以下问题:C# ST.Size方法的具体用法?C# ST.Size怎么用?C# ST.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ST
的用法示例。
在下文中一共展示了ST.Size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SymbolGraph
private readonly ST<string, Integer> _st; // string -> index
#endregion Fields
#region Constructors
/// <summary>
/// Initializes a graph from a file using the specified delimiter.
/// Each line in the file contains
/// the name of a vertex, followed by a list of the names
/// of the vertices adjacent to that vertex, separated by the delimiter.
/// </summary>
/// <param name="lines">array of string lines</param>
/// <param name="delimiter">delimiter the delimiter between fields</param>
public SymbolGraph(IList<string> lines, char delimiter)
{
_st = new ST<string, Integer>();
// First pass builds the index by reading strings to associate
// distinct strings with an index
// while (in.hasNextLine()) {
foreach (var line in lines)
{
var a = line.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
foreach (var word in a)
{
if (!_st.Contains(word))
_st.Put(word, _st.Size());
}
}
Console.WriteLine("Done reading");
// inverted index to get string keys in an aray
_keys = new string[_st.Size()];
foreach (var name in _st.Keys())
{
_keys[_st.Get(name)] = name;
}
// second pass builds the graph by connecting first vertex on each
// line to all others
G = new Graph(_st.Size());
foreach (var line in lines)
{
var a = line.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
int v = _st.Get(a[0]);
for (var i = 1; i < a.Length; i++)
{
int w = _st.Get(a[i]);
G.AddEdge(v, w);
}
}
}