是否有可能在一個向量中使用一對make_heap()
?std :: make_heap with pairs
我使用:
std::vector< std::pair < int , tablero& > > lista_abierta_;
我使用對象函數訂購一對由所述第一構件,但它會崩潰。
的代碼是:
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include "8_puzzle.h"
#include "tablero.h"
using namespace std;
class comp {
public:
bool operator()(pair < int, tablero&> a, pair < int, tablero&> b) const {
return a.first > b.first;
}
};
pair < int, tablero& > puzzle::A_estrella::tope()
{
pair < int, tablero& > l=lista_abierta_.front();
pop_heap(lista_abierta_.begin(),lista_abierta_.end());
lista_abierta_.pop_back();
return l;
}
嗨NSB,歡迎堆棧溢出。請根據[格式指南](http://stackoverflow.com/editing-help)嘗試格式化您的文章。謝謝。 – jpjacobs 2012-01-06 12:25:41
你不能在標準容器內有一個'_reference_對,你可以嗎? – 2012-12-29 03:59:08