0
'left'std :: std :: set 对于left(设置)中的每个元素,我试图通过迭代'left'来设置联合操作到另一个set, 。set union is not working
为什么下面的代码无法正常工作。我正在尝试设置两组的联合。
std::vector<std::set<int> > left(num_nodes);
//Both leftv and left are not empty ....there is some code here which fills them.
std::set<int> leftv, dummy;
for(std::set<int>::iterator u = leftv.begin(); u != leftv.end() ;u++){
dummy.insert(v); //v is some integer
std::set_union (left[*u].begin(), left[*u].end(), dummy.begin(), dummy.end(), left[*u].begin());
dummy.clear();
}
错误 /usr/include/c++/4.3/bits/stl_algo.h:5078:错误:__result.std :: _ Rb_tree_const_iterator < _TP> ::运营商的只读位置”分配*与_TP = int'
你能精心** **什么是不工作。编译器错误?运行时崩溃? –
您的问题不在联合中,而是您尝试迭代的方式。你想结合在一起的是什么? (leftv只是左边的所有集合的联合?) – IdeaHat
如果这是所有相关的代码,当'for'循环到达时'leftv'为空,所以你没有什么可以迭代。 – Angew