title: C++ Saving objects inside a list to reuse later
body: <p>Suppose I own a list of edges saved inside a vector like:</p>
  <pre><code>typedef struct edge
  {
    int v;
    size_t start;
    size_t end;
  }e;
  
  typedef vector&lt;list&lt;e&gt;&gt; adj_list;
  adj_list tree;
  </code></pre>
  <p>I have to do logic on this <code>tree</code> object, but the logic is too complicated to do it in place (constricted to not recurse). I need an extra data structure to handle each node. As a simple example, lets consider incrementing each edge's v value:</p>
  <pre><code>list&lt;e&gt; aux;
    aux.insert(aux.begin(), tree[0].begin(), tree[0].end());
    while (!aux.empty())
      {
        e&amp; now = aux.front();
        aux.pop_front();
        now.v++;
        aux.insert(aux.begin(), tree[now.v].begin(), tree[now.v].end());
        
      }
  </code></pre>
  <p>The problem in doing this is that the changes made to the <code>now</code> variable does not reflect the value in <code>tree</code>. I need a list(can be any list(vector,linked,queue,stack) that has an empty() boolean like Dijkstra) ds to handle my <code>edge</code> objects in <code>tree</code>. Is there an elegant way to do this? Can I use a list of iterators? I'm specifically asking an &quot;elegant&quot; approach in hopes that it does not involve pointers.</p>