struct node
{
node *right;
node *left;
int data;
};
這是我的結構節點。 現在我正在使用順序STL優先級隊列中提取分鐘即最小從優先級隊列這樣如何創建節點結構類型的Min stl priority_queue
std::priority_queue<node*, std::vector<node*>, std::greater<node*> > mypq;
但我沒有得到的最小和google搜索,我發現(較大),它用於整數,我得到了另一個答案,我實現這樣的
struct compare
{
bool operator()(const node*& l, const node*& r)
{
return l > r;
}
};
而且我用這樣的
std::priority_queue<node*, std::vector<node*>,compare > mypq;
但它顯示錯誤,我很沮喪,任何BOD請幫助我
偉大的一點,我總是錯過''const''。 – gongzhitaao 2013-03-26 17:21:14