title: hash map for small number of items
body: <p>I have a scenario where I need 0-10000 objects that are clearly associated with the numbers of 0-10000. These objects should be stored efficiently and have a fast lookup time. However, some container that manages them would be rather sparsely filled.</p>
  
  <p>For example, I might have 100 objects with the corresponding associated numbers of 0-99 and some other 150 objects with the corresponding associated numbers of 650-799.</p>
  
  <p>My first thought here would be some hash map: The hash functions is perfectly easy to calculate. A bare vector would need a binary search for finding elements, which seems slower than a table lookup. I could also use an array with pointers, but I would have the pointer overhead.</p>
  
  <p>Now, if I would like to use a hashmap, which one? I have recently read that <code>unorderd_map</code> would have quite some overhead. But another requirement here is that the map should also be memory efficient.</p>
  
  <p>So I am wondering which is the best container for my purpose. I would like to use some std container or a boost container but am also open to other third-party containers if they are available under LGPL or other free closed-source and commercially usable licenses.</p>
  
  <p>The requirements again:</p>
  
  <ul>
  <li>I need an (associative) container that maps a number (<code>int</code>) against an object</li>
  <li>lookup time should be as fast as possible</li>
  <li>the container will have up to 10000 elements, so the container should also be performance- and memory-efficient for a small number of entries</li>
  <li>(<em>added after reading comments</em>): the container should be fast to copy. The container is used in some other class, lets call it <code>HoldingClass</code>, which I have thousands of instances of. All of those instances are copied from time to time, which should be as fast as possible. That's also where the memory overhead should be low because the copies are stored in my application</li>
  <li>(<em>added after reading comments</em>): inserting and removing from the container apart from copying the entire container is infrequent and not performance-critical</li>
  </ul>
  
  <p>So, what seems to be the best possible container for this specific case?</p>