insertion d'une liste definie dans une structure
Bonjour, J'ai un petit problème au niveau mon tp:
j'ai une structure et je veux inséré es élément d'une liste dans mon arbre map:
voici la structure
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
struct Sommet{
mutable bool visite;
set<std::string> voisins;
Coordonnee coor;
Sommet(Coordonnee const & c):coor(c){}
list <std::string> route;
};
map<std::string, Sommet> sommets; |
je veux insérer une liste es routes pour chaque points
voici ma fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
void Carte::ajouterRoute(const string& nom, list<string>& listeNoms){
for(list<std::string>::const_iterator itr = listeNoms.begin();itr!=listeNoms.end();++itr){
map<std::string ,Sommet>::iterator iter=sommets.find(*itr);
if(iter!=sommets.end()){
//iter->second.route = nom;
iter->second.route.insert(nom); // ici le problème d'insertion
//sommets.at(s1).voisins.insert(s2);
// cout <<"iter route "<< iter->first;
cout << iter->first <<" , "<< iter->second.route;
cout << endl;
// cout <<"iter nom "<< nom;
cout << endl;
}
}
} |