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

📄 priorityqueuenode.java

📁 Dijkstra algorithm in Java.
💻 JAVA
字号:
/*
 * PriorityQueueNode.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 PriorityQueueNode 
{
    PriorityQueueNodeElement m_head;
    
    /** Creates a new instance of PriorityQueueNode */
    public PriorityQueueNode() 
    {
        m_head = null;
    }
    
    public void Push(Node node)
    {
        if (m_head == null)
            m_head = new PriorityQueueNodeElement(node);
        else
            m_head.Push(node);
    }
    
    // Pop's front
    public PriorityQueueNodeElement Pop()
    {
        PriorityQueueNodeElement temp = m_head;
        if (m_head!=null)
        {
            m_head = m_head.m_next;
            if (m_head!=null)
               m_head.m_prev = null;
        }
        return temp;
    }
    
    public void ReMap(PriorityQueueNodeElement elem)
    {
        assert(elem!=null);
        
        if (elem.m_prev!=null)
            elem.m_prev.m_next = elem.m_next;
        else if (elem == m_head)
        {
            m_head = m_head.m_next;
        }
                   
        m_head.Push(elem.m_pNode);
    }
    
    public void ReMap(Node node)
    {
        assert(node!=null);
        
        if (m_head!=null)
        {
            PriorityQueueNodeElement elem = m_head;
            while(elem!=null)
            {
                if (elem.m_pNode == node)
                {
                    ReMap(elem);
                    break;
                }
                elem = elem.m_next;
            }
            
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -