Re: [boost] [unordered] unordered_set::erase() complexity bug?

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() ? Chris Crickmar

On 18 March 2010 09:54, Christopher Crickmar <cjcrickmar@googlemail.com> 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

On 18 March 2010 11:10, Daniel James <dnljms@gmail.com> wrote:
On 18 March 2010 09:54, Christopher Crickmar <cjcrickmar@googlemail.com> 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.
participants (2)
-
Christopher Crickmar
-
Daniel James