Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Have a look at this: <a href="http://code.google.com/p/google-sparsehash/" rel="nofollow noreferrer">Google Sparse Hash Map</a>. It's been my favorite C++ library since I stumbled upon it some years ago.</p> <p>Its performance is incredible, has both a map and a set class, and has the asked-for reserve functions. I've switched over countless projects from various other map-like datastructures to google sparsehash with incredible results. The syntax is drop-in compatible with the C++0x <code>unordered_map</code> (terrible, terrible name!), but has extra functions and features as well.</p> <p>Internally, it is implemented with a hash table using the sparsehashing technique.</p> <p>EDIT (May 13, 2015)</p> <p>As this has become a popular answer, I just wanted to point out two other map-like structures I have been using in recent years. The <a href="https://launchpad.net/libmct" rel="nofollow noreferrer"><strong>M</strong>iscellaneous <strong>C</strong>ontainer <strong>T</strong>emplates (MCT) library</a> provides drop-in compatible high-performance unorderd_map implementations in a few varieties:</p> <blockquote> <p>It provides six general-purpose hash table containers — closed_hash_set, closed_hash_map, linked_hash_set, linked_hash_map, forward_hash_set and forward_hash_map. The first two are very similar to TR1 unordered_set and unordered_map. The linked ones provide additional functionality, while forward hash tables are more efficient than linked, but have restricted interface. In some cases performance of the closed_hash_* containers can be improved even further with optional intrusiveness support.</p> </blockquote> <p>And <a href="https://github.com/facebook/folly" rel="nofollow noreferrer">folly</a> by facebook has some really great structures. They don't have a drop-in unordered_map replacement per-se, but there's a lock-free/thread-safe implementation of unordered_map and building things around <code>fbvector</code> can result in huge performance gains due to better memory usage and layout.</p> <p>In my testing, for single-threaded code Google's <code>dense_hash_map</code> is still my preferred option for maximum performance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload