我有一個Boost unordered_map是否僅用於將項目與整數相關聯?
HashMap<Node, Double>
在Java中
,我會用以後檢索與節點相關聯的兩倍。我試着做
boost::unordered_map<Node*, double>
但我得到一個「錯誤C2108:標不是整體式的」當我試圖把東西在裏面,比如:
map[some_node] = some_double;
如果我解釋錯誤的權利,那麼我必須用int替換我的double。有沒有簡單的方法呢?
沒關係,這裏的功能,那麼:
void myClass::someFunction(const double* r)
{
//map is boost::unordered_map<Node*, double>
//nodes is a pointer to std::vector<Node*>
std::vector<Node*>::iterator it;
for(it = nodes->begin(); it != nodes->end(); it++)
{
//calculate the index
map[*it] = r[index]; //error
}
}
雖然這不是我正在尋找的,但你是對的。最好將double添加到Node中。 – zxcvbnm 2010-01-18 17:31:53