本文整理汇总了C#中OrderedBag.RangeFrom方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedBag.RangeFrom方法的具体用法?C# OrderedBag.RangeFrom怎么用?C# OrderedBag.RangeFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderedBag
的用法示例。
在下文中一共展示了OrderedBag.RangeFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Testing priority queue
var testQue = new PriorityQueue<int>();
testQue.Enque(1);
testQue.Enque(5);
testQue.Enque(-87);
testQue.Enque(67);
testQue.Enque(98);
testQue.Enque(6765);
testQue.Enque(12);
testQue.Enque(1);
testQue.Enque(-2);
testQue.Enque(-5);
testQue.Enque(1);
testQue.Enque(1);
testQue.Enque(231);
testQue.Enque(11);
int numberOfEntries = testQue.Count;
for (int i = 0; i < numberOfEntries -1; i++)
{
Console.WriteLine(testQue.Dequeue());
}
// Testing products task
OrderedBag<Product> tryBag = new OrderedBag<Product>();
tryBag.Add(new Product("Mlqko", 55.76M));
tryBag.Add(new Product("Hlqb", 56M));
tryBag.Add(new Product("Maslo", .6M));
tryBag.Add(new Product("Kroasan", 5.76M));
tryBag.Add(new Product("Biskviti", 5.76M));
tryBag.Add(new Product("Zele", 355.76M));
tryBag.Add(new Product("Fystyci", 765.76M));
tryBag.Add(new Product("Shokolad", 1.76M));
var fromRangeProduct = new Product("test", 5m);
var currentView = tryBag.RangeFrom(fromRangeProduct, true);
foreach (var product in currentView)
{
Console.WriteLine("{0} has price of -> {1}", product.Name, product.Price);
}
// Test counting words
string testText = "the ther the ther thir them t a m";
string[] words = testText.Split(' ');
Trie checkIt = new Trie();
for (int i = 0; i < words.Count(); i++)
{
checkIt.Insert(words[i]);
}
var result = checkIt.CountWords();
foreach (var pair in result)
{
Console.WriteLine("The word === {0} === can be found === {1} === times in the text", pair.Key, pair.Value);
}
}