Boost logo

Boost Users :

From: Ramesh (rramesh1_at_[hidden])
Date: 2008-08-12 14:40:41


Thanks Joaquín,

Will try modify & the reasons I am wrapping the map class with a another one
is to make sure that the users of the class just get access to APIs and not
to the container as such & and also each key is used by a different classes
to do lookups. Hence two unique keys.

Thanks for your response.

Regards
Ramesh

On Tue, Aug 12, 2008 at 11:31 AM, JOAQUIN M. LOPEZ MUÑOZ <joaquin_at_[hidden]>wrote:

> Hi Ramesh,
>
> ------------------------------
> *De:* boost-users-bounces_at_[hidden] [
> boost-users-bounces_at_[hidden]] En nombre de Ramesh [
> rramesh1_at_[hidden]]
> *Enviado el:* martes, 12 de agosto de 2008 7:40
> *Para:* boost-users_at_[hidden]
> *Asunto:* [Boost-users] Multi-index container (Modifying non-unique key in
> the container)
> >
> > Hi.
> >
> > I am using boost multi-index container for storing objects of type class
> A, in the class key1 &
> > Key 3 are unique and key2 is non-unique. I try to insert objects of type
> A and it works fine.
> > No issues.
> >
> > At some point after the insertion, I wish to modify the key2 to 20 in
> the container. Can I do this
> > with modify? If yes How do I define the iterator (since I need to do a
> find based on key1 but
> > modify key2 in the container)
>
> You have two options:
>
> 1. Use modify(), which is passed the entire element rather than the key,
> and
> modify key2 at your pleasure.
> 2. Project the key1-iterator to a key2-iterator using the projection
> facilities:
>
> http://www.boost.org/libs/multi_index/doc/tutorial/basics.html#projection
>
> and then use modify_key() with the key2-iterator.
>
> BTW, I've noticed that you're wrapping the A objects into a DataMap class
> that, oddily enough, replicates the key1, key2 and key3 members. Why aren't
> you using A members directly thus disposing of the DataMap wrapper?
>
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
>
> _______________________________________________
> 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