穿越总之我的问题,在“unordered_map”我会加入一对,名称以数字,并将其发送给一个函数。 (功能不要紧它做什么。)于是我将增加的另一件事到图形的地图,但我希望能够穿越到我添加到列表中的下一件事,因为我想扔标记的名字进入功能。C++,如何通过unordered_map
下面是一些代码
unordered_map<string,int> graph;
unordered_map<string,int>:: iterator it;
using namespace std;
int main(){
string name;
graph.insert(pair<string,int>("Sue",4));
it=graph.begin();
name = it -> first; //name is equal to "Sue"
function(name);
graph.insert(pair<string,int>("Mark",83));
it++ // this will not work
name = it -> first; //this will not end up equaling to "Mark"
function(name);
}
做++it
不行,倒退--it
,没有工作过。
那么有没有人有一个解决方案,我可以倒退得到name = it -> first
为Mark
?
注:(我会做这个方法太多次,因为它会进入一个循环)
你说的“接下来的事情”是什么意思?接下来按什么顺序? –
@TemplateRex我所做的唯一事情就是编辑文本。我从来没有(永远)删除或考虑删除标签。 (如果这样的事情发生的情况是不情愿还是你错) – Ziezi
@simplicisveritatis好,编辑历史表明,你删除它,但没有问题,如果它是偶然! – TemplateRex