本文整理汇总了C#中PriorityQueue.Size方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.Size方法的具体用法?C# PriorityQueue.Size怎么用?C# PriorityQueue.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.Size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethodSizeAndPushAndPop
public void TestMethodSizeAndPushAndPop()
{
PriorityQueue<double> testQueue = new PriorityQueue<double>();
testQueue.Push(1,2);
testQueue.Pop();
Assert.IsTrue(testQueue.Size() == 0);
}
示例2: BranchAndBound
public ArrayList BranchAndBound(City[] Cities, ArrayList Route, double BSSF)
{
Node startNode = new Node(Cities);
startNode.initStaticMembers();
PriorityQueue pQ = new PriorityQueue(startNode);
ArrayList bbRoute = null;
Stopwatch timer = new Stopwatch();
timer.Start();
//while ((pQ.Size() > 0) && (pQ.Peek() < BSSF) && (timer.Elapsed.TotalMinutes < 10))
while ((pQ.Size() > 0) && (pQ.Peek() < BSSF) && (timer.Elapsed.TotalSeconds < 30))
{
// Keep track of the largest size of the queue
if (pQ.Size() > Node.maxNodesCreated)
{
Node.maxNodesCreated = pQ.Size();
}
startNode = pQ.DeleteMinimum();
//startNode.matrix2Table();
// Check for a solution
if (startNode.includedEdges == Cities.Length)
{
ArrayList tempRoute = new ArrayList();
if (!startNode.exited.Contains(-1))
{
int index = 0;
while (tempRoute.Count < Cities.Length)
{
tempRoute.Add(Cities[startNode.exited[index]]);
index = startNode.exited[index];
}
BSSF = startNode.lowerBound;
bbRoute = tempRoute;
Node.numSolutions++;
}
}
Node incNode = new Node(startNode);
Node excNode = new Node(startNode);
Node maxInclude = null;
Node maxExclude = null;
double maxDiff = -1;
double diff = 0;
int maxRow = 0;
int maxCol = 0;
for (int row = 0; row < startNode.matrixSize; row++)
{
for (int col = 0; col < startNode.matrixSize; col++)
{
if (startNode.rcMatrix[row, col] == 0)
{
Node includeNode = new Node(incNode, true, row, col);
Node excludeNode = new Node(excNode, false, row, col);
diff = excludeNode.lowerBound - includeNode.lowerBound;
Node.numStatesCreated += 2;
if (diff > maxDiff)
{
maxDiff = diff;
maxRow = row;
maxCol = col;
maxInclude = new Node(includeNode);
maxExclude = new Node(excludeNode);
}
}
}
}
if (maxInclude != null && maxInclude.lowerBound < BSSF)
{
pQ.Insert(maxInclude);
}
else
{
Node.pruneCount++;
}
if (maxExclude != null && maxExclude.lowerBound < BSSF)
{
pQ.Insert(maxExclude);
}
else
{
Node.pruneCount++;
}
}
timer.Stop();
Node.timeElapsed = timer.ElapsedMilliseconds;
if (bbRoute == null)
{
return Route;
//.........这里部分代码省略.........
示例3: TestMethodSize
public void TestMethodSize()
{
PriorityQueue<double> testQueue = new PriorityQueue<double>();
Assert.IsTrue(testQueue.Size() == 0);
}