title: C++: Map, previous item of a key
body: <p>I have this map: <code>map&lt;int, int &gt; items</code>.
  Given a key, I want that this map returns the item corrisponding to the key if it present, otherwise the map returns the item with key immediately less than the given key.
  For example, if I have: </p>
  
  <pre><code>  items[0]=0;
    items[6]=10;
    items[15]=18;
    items[20]=22;
  </code></pre>
  
  <p>than for key=15, I want that the map returns item with value 18, otherwise for key=9, I want that map returns item with value 10.</p>
  
  <p>I  haven't find a function for this case. But I tried in this way:</p>
  
  <pre><code>itlow=items.lower_bound(key);
  if(!items.count(key))
     itlow--;
  return itlow-&gt;second;
  </code></pre>
  
  <p>This works as I want, entering in the map a min value <code>items[0]=0</code> for default, but I know that <code>itlow--;</code> it's not good programming. How can I do? thanks all. </p>