Boost logo

Boost Users :

Subject: Re: [Boost-users] [Unordered] Penultimate Iterator
From: Nat Goodspeed (nat_at_[hidden])
Date: 2010-09-10 20:07:28


On Sep 10, 2010, at 10:39 AM, Hossein Haeri <powerprogman_at_[hidden]>
wrote:

> 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?
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net