Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] Couple of questions on multi-index containers
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2014-09-29 13:25:02


Hello Joaquin,

I just came up with a slightly different question in more or less same
direction. Can I safely erase data from the index view in a range based for
loop. The index container contains only ordered indices (no random access).

I saw a suggestion that an iterator is being invalidated and therefore
pre-incrementing it for the next step is fine. But what happens if an
element erased via its key itself in a range-based for-loop? Would the next
increment work fine?

Many thanks,
Ovanes

On Sun, Sep 28, 2014 at 4:03 PM, Aaron Levy <aaron.levy_at_[hidden]> wrote:

>
>
> 28.09.2014, 19:06, "Joaquin M Lopez Munoz" <joaquin_at_[hidden]>:
> > Aaron Levy <aaron.levy <at> yandex.com> writes:
> >> If I erase elements in a multi_index_container, how are iterators
> >> invalidated?
> >> 1. For other than random_access index, only iterators to the deleted
> >> element?
> >> 2. For random_access index, potentially any iterator?
> ...
> >
> > For all indices, on every ocassion, only the iterators to the deleted
> > element are invalidated.
> >> What are the data structures used internally for this container and its
> >> indexes.
> >
> > * random-access indices use this:
> >
> > http://bannalia.blogspot.com/2008/08/stable-vectors.html
> >
>
> Aah! Random access and stable, I should have guessed stable_vectors.
>
> And the pointers to the implementation are impressive.
>
> Thanks.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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