title: Get first available key in map
body: <p>I have a map that stores pointers to an object by their ID.</p>
  
  <pre><code>typedef std::map&lt;unsigned int, Entity*&gt; entityMap;
  entityMap entitymap;
  </code></pre>
  
  <p>To assign an ID to Entity I could just take the newest value in entitymap and increase it by 1.</p>
  
  <pre><code>Entity *entity = new Entity;
  entity-&gt;id = /*newest entity+1*/;
  entitymap.insert(std::pair&lt;unsigned int,Entity*&gt;(entity-&gt;id,entity));
  </code></pre>
  
  <p>But the number could become unnecessarily big because every now and then an Entity is deleted and removed from the map.</p>
  
  <pre><code>std::map&lt;unsigned int,Entity*&gt;::iterator it;
  it = entitymap.find(EntityID);
  if(it != entitymap.end())
  {
      Entity *entity= it-&gt;second;
      entitymap.erase(it);
  }
  delete entity;
  </code></pre>
  
  <p>So I could have a map that holds these values;</p>
  
  <pre><code>1,2,4,8,10
  </code></pre>
  
  <p>In which case I'd like the next Entity to claim the ID <code>3</code>.</p>