How efficient is the find() function on the std::map class? Does it iterate through all the elements looking for the key such that it\'s O(n), or is it in a balanced tree, o
It does not iterate all elements, it does a binary search (which is O(log(n))). It use operator< or a comparator to do the search.
If you want a hash map, you can use a std::unordered_map (added on C++-0x), which use a hash function and on average (depending on the hash function and data you provide) find() will be O(1).