⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 priorityqueuenodeelement.java

📁 Dijkstra algorithm in Java.
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -