priorityqueuenodeelement.java
来自「Dijkstra algorithm in Java.」· Java 代码 · 共 62 行
JAVA
62 行
/*
* PriorityQueueNodeElement.java
*
* Created on June 1, 2007, 11:38 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package termproject_dijkstra;
/**
*
* @author Peto
*/
public class PriorityQueueNodeElement
{
Node m_pNode;
PriorityQueueNodeElement m_prev,m_next;
/** Creates a new instance of ListElement */
public PriorityQueueNodeElement(Node node)
{
m_pNode = node;
m_prev = null;
m_next = null;
}
public Node GetNode()
{
return m_pNode;
}
// Sorted by weight ascendingly, allow same nodes with different weights
public void Push(Node node)
{
if (node.m_iDist <= m_pNode.m_iDist)
{
PriorityQueueNodeElement temp = new PriorityQueueNodeElement(node);
// Swap data so we don't have to check wheter its pointed by PQ.head
temp.m_prev = this;
temp.m_next = m_next;
temp.m_pNode = m_pNode;
m_next = temp;
m_pNode = node;
}
else if (m_next!=null)
m_next.Push(node);
else
{
m_next = new PriorityQueueNodeElement(node);
m_next.m_prev = this;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?