Boost logo

Boost :

Subject: Re: [boost] [unordered] unordered_set::erase() complexity bug?
From: Christopher Crickmar (cjcrickmar_at_[hidden])
Date: 2010-03-18 08:44:57


On 18 March 2010 11:10, Daniel James <dnljms_at_[hidden]> wrote:

> On 18 March 2010 09:54, Christopher Crickmar <cjcrickmar_at_[hidden]>
> wrote:
> > Given that the next iterator is meaningless for an unordered container
> and
> > that cached_begin_bucket_ is always valid would it be bad manners to
> always
> > return begin() ?
>
> The next iterator isn't meaningless, the elements in a container have
> a sequence. While it isn't fixed, it never changes due to an erase.
> The main reason for returning the next iterator is so that you can
> iterate through a container erasing elements as you go, returning
> 'begin()' would break that.
>
> Daniel

Far point regarding the order of iteration however it does seem perverse
that an unordered container gives any guarantees regarding the sequence of
iteration.

Erasing in a loop would still work as begin() is still a valid iterator...or
am I missing something.

ChrisC.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk