Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Depending on what you required, it can still be significantly faster than std::map. Any tree-based data structure is going to play havoc with cache. Also, it will perform an allocation for every single node inserted, which can become rather expensive (unless you're using some customized allocator for this).

Honestly, sorted vectors can often be a good replacement, depending on the workload, if you must have ordered data (this is what boost flat_map uses). All 3 (map, unordered_map, sorted vector) can have their uses, depending on what you are doing with the data.

If you need a better performing hash map, there's always Abseil as well.



Unfortunately unordered_map also requires lots and lots of allocations, because it's forced to use linked-list buckets.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: