Boost logo

Boost Users :

From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2008-08-24 17:55:28


(Excuse the slow pace of this thread, I've been on vacation with little
access to the Internet).

________________________________
De: boost-users-bounces_at_[hidden] [boost-users-bounces_at_[hidden]] En nombre de Ramesh [rramesh1_at_[hidden]]
Enviado el: jueves, 21 de agosto de 2008 0:17
Para: boost-users_at_[hidden]
Asunto: Re: [Boost-users] Multi-index container (Modifying non-unique key in the container)

On Wed, Aug 20, 2008 at 8:02 AM, JOAQUIN M. LOPEZ MUÑOZ <joaquin_at_[hidden]<mailto:joaquin_at_[hidden]>> wrote:

Yes, but DataMap seems to *replicate* the keys that are already
present in A. Cannot you just have the following?

typedef multi_index_container<
  A*,
    indexed_by<
        ordered_unique<
            tag <Key1>, BOOST_MULTI_INDEX_MEMBER(A,std::string,Key1)>,
        ordered_non_unique<
                  tag<Key2>,BOOST_MULTI_INDEX_MEMBER(A,long,Key2)>,
              ordered_unique<
                  tag<Key3>,BOOST_MULTI_INDEX_MEMBER(A,long,Key3)>
>
> tDMap;

[...]
>

> If I would remove the keys the map would just hold pointers and I wouldnt be able to
> do lookups based on the keys (to retrieve pointers to objects based on keys) if I wouldnt
> pair the pointers with they keys in the Map - thats why I have the keys in the map, please
> correct me if am wrong.
You can use the members of the pointed to objects of type A as keys of your container.
This is discussed in detail at:

http://www.boost.org/libs/multi_index/doc/reference/key_extraction.html#chained_pointers

In particular, I think that the tDMap definition I gave above should work directly. Please
report back if this is not the case.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo



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