本文整理汇总了C#中WordLibraryList.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# WordLibraryList.Sort方法的具体用法?C# WordLibraryList.Sort怎么用?C# WordLibraryList.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WordLibraryList
的用法示例。
在下文中一共展示了WordLibraryList.Sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTree
/// <summary>
/// 构造一棵词库的树
/// </summary>
/// <param name="wlList"></param>
/// <returns></returns>
private TouchPalChar BuildTree(WordLibraryList wlList)
{
//先对词库进行排序再生成词库树
wlList.Sort((a, b) => a.Word.CompareTo(b.Word));
WordLibrary rootWL = wlList[0];
var rootChar = new TouchPalChar(); //这个只是一个根Char,没有实际的字
TouchPalChar lastChar = AddWordLink2Char(rootChar, rootWL, 0);
for (int i = 1; i < wlList.Count; i++)
{
WordLibrary wl = wlList[i];
wl.Count = 96; //默认是96的词频
string a = lastChar.Word.ChineseWord;
string b = wl.Word;
int len = FindSameWordLen(a, b);
if (len == 0)
{
lastChar = AddWordLink2Char(rootChar, wl, 0);
}
else
{
lastChar = AddWordLink2Char(lastChar, wl, len);
}
}
return rootChar;
}
示例2: Filter
public WordLibraryList Filter(WordLibraryList list)
{
if (Percentage == 100)
{
return list;
}
int count = list.Count*Percentage/100;
list.Sort((a, b) => a.Rank - b.Rank);
var result = new WordLibraryList();
for (int i = 0; i < count; i++)
{
result.Add(list[i]);
}
return result;
}