本文整理汇总了C#中PriorityQueue.DeleteExtreme方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.DeleteExtreme方法的具体用法?C# PriorityQueue.DeleteExtreme怎么用?C# PriorityQueue.DeleteExtreme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.DeleteExtreme方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
示例2: 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;
}
}
示例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: 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;
}
}
示例5: PriorityQueueIncreaseKeyTest
public void PriorityQueueIncreaseKeyTest()
{
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.55f);
Assert.AreEqual(0.1f, minpq.PeekExtreme());
minpq.ModifyValue(0.1f, 0.22f);
Assert.AreEqual(0.2f, minpq.PeekExtreme());
minpq.ModifyValue(0.5f, 500f);
minpq.Insert(100f);
minpq.Insert(501f);
float last = 0.0f;
while (!minpq.IsEmpty)
{
float curr = minpq.DeleteExtreme();
Assert.AreNotEqual(0.4f, curr);
Assert.Greater(curr, last);
last = curr;
}
}
示例6: PriorityQueueDuplicateElementsTest
public void PriorityQueueDuplicateElementsTest()
{
var values = new[] { 3, 3, 3, 5, 3, 3, 3, 3 };
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(5, maxpq.DeleteExtreme());
while (!maxpq.IsEmpty)
{
int curr = maxpq.DeleteExtreme();
Assert.AreEqual(3, curr);
}
}