The first element. Constant time on average: the map keeps a lower bound on its first non-empty bucket, which insertion lowers and erase(iterator) raises, so while (!m.empty()) m.erase(m.begin()); is linear. begin() itself writes nothing, so concurrent calls are safe.
Declared in <cptr/unordered_map.hpp>
The first element. Constant time on average: the map keeps a lower bound on its first non-empty bucket, which insertion lowers and erase(iterator) raises, so while (!m.empty()) m.erase(m.begin()); is linear. begin() itself writes nothing, so concurrent calls are safe.
iterator
begin() noexcept;
» more...
const_iterator
begin() const noexcept;
» more...