11 Sep
2010
11 Sep
'10
12:07 a.m.
On Sep 10, 2010, at 10:39 AM, Hossein Haeri
What is the quickest way to get hold of the penultimate iterator in an unordered_map? I'm aware of this one -- which is O(n), where n == container_.size():
container_type::const_iterator i = container_.begin(); advance(i, container_.size() - 1);
Is there no O(1) solutions?
Not at my computer, sorry... rbegin().base() ? But your question implies that order matters - if you don't mind my asking, why use an unordered_map if order matters?