?? priority_queue.h
字號:
#ifndef PRIORITY_QUEUE_H
#define PRIORITY_QUEUE_H
#define MAX_NUM 200 //優(yōu)先隊列里最多能存的元素個數(shù)
typedef struct Edge
{
int v; //起點
int w; //終點
int weight; //邊的權(quán)值
}Edge;
/**---每次只能出隊列中的最小值的優(yōu)先隊列----*/
typedef struct priority_queue
{
struct Edge* h[MAX_NUM+1]; //用來存優(yōu)先隊列里的元素的,元素從1開始存,
int n ; // 元素存放時應(yīng)該放的位置,
} priority_queue;
Status init_priority_queue(priority_queue* pq);
//初始優(yōu)先隊列
//Edge* IninEdge(int a,int b,int c);
//初始化優(yōu)先隊列里面的元素
Status Destory_priority_queue(priority_queue* pq);
//銷毀優(yōu)先隊列
Status max_heapify(priority_queue* pq,int i);
//每次插入后進行的堆調(diào)整,因為每次都插入到最后,前面的元素都符合堆的要求,
//調(diào)整成功返回0,不成功返回-1
int min_heapAdjust(priority_queue* pq,int n);
//已知pq[1....n]中記錄的關(guān)健字除pq[1]外均滿足堆的定義,本函數(shù)調(diào)整L[1]的關(guān)健字
//使L[1...m]成為一個小頂堆,調(diào)整成功返回0,不成功返回-1
Status insert_priority_queue(priority_queue* pq,Edge* t);
//向隊列pq中插入一元素 t, 操作成功返回0,操作失敗返回-1
Edge* extract_min(priority_queue* pq);
//隊列pq中返回最小值,并刪除了最小值
Edge* Get_Min(priority_queue* pq);
//僅僅從隊列pq中獲得了最小值
int isEmpty(priority_queue* pq);
//隊列為空返回true, 否則返回false
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -