update map value
<p>I have a map like this:</p>

<pre><code>map&lt;prmNode,vector&lt;prmEdge&gt;,prmNodeComparator&gt; nodo2archi;
</code></pre>

<p>When I have to update the value (vector), I take the key and his value, I update the vector of values, I erase the old key and value then I insert the key and the new vector. The code is this:</p>

<pre><code>bool prmPlanner::insert_edgemap(int from,int to) {

  prmEdge e;
  e.setFrom(from);
  e.setTo(to);

  map&lt;prmNode,vector&lt;prmEdge&gt; &gt;::iterator it;

  for (it=nodo2archi.begin(); it!=nodo2archi.end(); it++){
      vector&lt;prmEdge&gt; appo;
      prmNode n;
      n=(*it).first;
      int indice=n.getIndex();

      if (indice==f || indice==t){
          appo.clear();
          vector&lt;prmEdge&gt; incArchi;
          incArchi=(*it).second;
          appo=(incArchi);

          appo.push_back(e);

          nodo2archi.erase(it);
          nodo2archi.insert(make_pair(n,appo) );
       }

    }
return true;
}
</code></pre>

<p>The problem is that for the first 40-50 iterations everything go weel and the map is updated well, while with more iterations it goes sometimes in segmentation fault, sometimes in an infinite idle. I don't know why. Somebody can help me please??
Thank you very much.</p>
