What’s the time complexity of iterating through a std::set/std::multiset/std::map/std::multimap? I believe that it is linear in the size of the set/map, but not so sure. Is it specified in the language standard?
What’s the time complexity of iterating through a std::set / std::multiset / std::map /
Share
In the C++11 working draft, the answer can be found in [iterator.requirements.general] p8:
Since each operation on an iterator must be constant time, iterating through
nelements must beO(n).