C++11 std::unordered_set and map are slower than a naive implementation
clifford.at
clifford.at
There's a big issue with the unordered_map.erase(const_iterator) method -- STL mandates that .erase() returns an iterator to the next item in the container. There's no simple implementation of that for hashtables other than to walk the hashtable, which is quite slow.
This was once a serious performance issue with unordered_map (discussion here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41975). I haven't followed up in years, but is the issue?
A similar problem exists for other types of STL containers but it is particularly acute for the map and set containers. Some programmers end up building their own library of map implementations, each implementation optimized for a different use case, to get around this problem. The number of template parameters you would need to generalize std::map would be ridiculous, so it is easier to just have a lot of specialized implementations.
For high-performance code, std::map and friends are usually the wrong choice. Personally, I always write usage optimized maps as needed these days; the first couple times seem tedious but it quickly turns into a simple idiom you can implement in your sleep.
It would be nice to see the specific code used to run the benchmarks, though.