本文整理汇总了C#中System.Collections.Queue.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Queue.ToList方法的具体用法?C# Queue.ToList怎么用?C# Queue.ToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Queue
的用法示例。
在下文中一共展示了Queue.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPage
public IEnumerable<Moneta> GetPage(string page)
{
var qq = new Queue<Moneta>();
var pagenum = 0;
int.TryParse(page, out pagenum);
var html = Helper.GetHtmlAsync(Constant.GetParentUrl(pagenum));
var table = Helper.GetSingleTag(html.Result, "table", "class", "adsmanager_table");
if (table != null)
foreach (var tr in table.Descendants("tr"))
{
var tdAdsmanager = Helper.GetSingleNodeTag(tr, "td", "class", "adsmanager_table_description");
var tdCenter = Helper.GetSingleNodeTag(tr, "td", "class", "center");
if (tdAdsmanager != null && tdCenter != null)
{
var regexCreateIn = Regex.Match(tdCenter.InnerHtml, Constant.RegexCreateDate,
RegexOptions.IgnoreCase | RegexOptions.Compiled);
var regexCount = Regex.Match(tdCenter.InnerHtml, Constant.RegexViewsCount,
RegexOptions.IgnoreCase | RegexOptions.Compiled);
var regexId = Regex.Match(tdAdsmanager.InnerHtml, Constant.RegexGetItemId,
RegexOptions.IgnoreCase | RegexOptions.Compiled);
var regexCatId = Regex.Match(tdAdsmanager.InnerHtml, Constant.RegexGetItemCatId,
RegexOptions.IgnoreCase | RegexOptions.Compiled);
if (!regexId.Success || !regexCatId.Success || !regexCreateIn.Success || !regexCount.Success)
continue;
var id = int.Parse(regexId.Groups[1].Value);
var catId = int.Parse(regexCatId.Groups[1].Value);
var date = DateTime.ParseExact(regexCreateIn.Value, "dd.MM.yyyy",CultureInfo.InvariantCulture);
var countViews = Helper.IntParce(regexCount.Groups[1].Value);
qq.Enqueue(GetItem(catId, id, date, countViews));
}
}
return qq.ToList();
}
示例2: MakeTableAndTree
public void MakeTableAndTree()
{
Queue<Symbol> currentQueue = new Queue<Symbol>();
Ensemble.OrderBy(o => o.Frequency).ToList().ForEach(p => currentQueue.Enqueue(p));
ProbabilityTable.Add(currentQueue.ToList());
while (currentQueue.Count > 1)
{
var newNode = new Symbol(currentQueue.Dequeue(), currentQueue.Dequeue());
var temporaryQueue = currentQueue.ToList();
if (currentQueue.Count == 0)
{
currentQueue.Enqueue(newNode);
}
else
{
int index = 0;
currentQueue.ToList().ForEach(p =>
{
if (newNode.Frequency <= p.Frequency)
{
index = currentQueue.ToList().IndexOf(p);
}
else
{
index++;
}
});
temporaryQueue.Insert(index, newNode);
currentQueue.Clear();
temporaryQueue.ForEach(p => currentQueue.Enqueue(p));
}
ProbabilityTable.Add(currentQueue.ToList());
}
}