title: How do I find previous and next key/value in a map?
body: <p>I have a map which has the following data:   </p>
  
  <pre><code>id    prev abundance  thing
  1573  -1      0       book
  1864  1573    39      beds
  2075  1864    41      tray
  1760  2075    46      cups
  </code></pre>
  
  <p>The map is:</p>
  
  <pre><code>map&lt;int id, Abund*&gt; oldMap;
  struct Abund
  {
  int prev;
  int abundance;
  string thing;
  }
  </code></pre>
  
  <p>I need to now create a new map which should look like this:</p>
  
  <pre><code> id2    prev2 prevAbun next2  nextAbun  thing2
   1573     -1            1864   39        book
   1864   1573     0      2075   41        beds
   2075   1864     39     1760   46        tray
   1760   2075     41                      cups
  </code></pre>
  
  <p>The previous and the next row from map 1 should become the columns in newMap
  So far I've created a new map and new struct:</p>
  
  <pre><code>struct NewAbund
  {
  vector&lt;int&gt; prev2;
  vector&lt;int&gt; prevAbun;
  vector&lt;int&gt; next2;
  vector&lt;int&gt; nextAbun;
  string thing2;
  }
  map&lt;int id2, NewAbund*&gt; newMap;
  </code></pre>
  
  <p>Now I have no idea how should the logic work for getting the previous row from oldMap and putting it as value in newMap. Thanks in advance!!</p>