[SOLVED] unordered_map: which one is faster find() or count()?


What is the fastest way to figure out if an unordered_map container has an item with a specified key?


They will have about equal performance. You should use the algorithm that best expresses what you are trying to do.

To elaborate on that, generally count() will be implemented using find(). For example, in libcxx, count() is implemented as return (find(__k) != end());

Answered By – Bill Lynch

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *