本文整理汇总了C#中System.Collections.Generic.PriorityQueue.DeleteExtreme方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.DeleteExtreme方法的具体用法?C# PriorityQueue.DeleteExtreme怎么用?C# PriorityQueue.DeleteExtreme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.DeleteExtreme方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PriorityQueueDecreaseKeyTest
public void PriorityQueueDecreaseKeyTest()
{
var minpq = new PriorityQueue<float>(new[] { 0.3f, 0.7f, 0.1f, 0.4f, 0.5f, 0.2f, 0.9f, 0.6f }, ExtremeType.Minimum);
Assert.AreEqual(0.1f, minpq.PeekExtreme());
minpq.ModifyValue(0.4f, 0.01f);
Assert.AreEqual(0.01f, minpq.PeekExtreme());
minpq.ModifyValue(0.01f, 0.001f);
Assert.AreEqual(0.001f, minpq.PeekExtreme());
float last = 0.0f;
while (!minpq.IsEmpty)
{
float curr = minpq.DeleteExtreme();
Assert.Greater(curr, last);
last = curr;
}
}
示例2: PriorityQueueMinTest
public void PriorityQueueMinTest()
{
var minpq = new PriorityQueue<int>(new[] { 3, 7, 1, 4, 5, 2, 9, 6 }, ExtremeType.Minimum);
int last = 0;
while (!minpq.IsEmpty)
{
int curr = minpq.DeleteExtreme();
Assert.Greater(curr, last);
last = curr;
}
}
示例3: PriorityQueueMaxTest
public void PriorityQueueMaxTest()
{
var maxpq = new PriorityQueue<int>(new[] { 3, 7, 1, 4, 5, 2, 9, 6 }, ExtremeType.Maximum);
int last = Int32.MaxValue;
while (!maxpq.IsEmpty)
{
int curr = maxpq.DeleteExtreme();
Assert.Less(curr, last);
last = curr;
}
}
示例4: PriorityQueueMinFloatTest
public void PriorityQueueMinFloatTest()
{
var minpq = new PriorityQueue<float>(new[] { 0.3f, 0.7f, 0.1f, 0.4f, 0.5f, 0.2f, 0.9f, 0.6f }, ExtremeType.Minimum);
float last = 0.0f;
while (!minpq.IsEmpty)
{
float curr = minpq.DeleteExtreme();
Assert.Greater(curr, last);
last = curr;
}
}
示例5: PriorityQueueInsertTest
public void PriorityQueueInsertTest()
{
var values = new[] { 3, 7, 1, 4, 5, 2, 9, 6 };
var maxpq = new PriorityQueue<int>(ExtremeType.Maximum);
Assert.IsTrue(maxpq.IsEmpty);
for (int i = 0; i < values.Length; i++)
{
maxpq.Insert(values[i]);
}
Assert.AreEqual(9, maxpq.DeleteExtreme());
maxpq.Insert(0);
maxpq.Insert(8);
int last = Int32.MaxValue;
while (!maxpq.IsEmpty)
{
int curr = maxpq.DeleteExtreme();
Assert.Less(curr, last);
last = curr;
}
}