Boost::MultiIndex or std::map

Hi: I am in a situation where by I need to be able to query an associative container. I need to fill the container before querying. The key is an integer and the vlaue is a std::string. Can I construct boost::multiIndex so as to allow key/value pairs to be entered at construction time or should I just use std::map and write a function. Any design advice apreciated. Note thi is going in to a dll with will return c-style types. Sean. __________ Information from ESET NOD32 Antivirus, version of virus signature database 3164 (20080606) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com

Hi Sean, ________________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Sean Farrow [sean.farrow@seanfarrow.co.uk] Enviado el: viernes, 06 de junio de 2008 19:26 Para: boost-users@lists.boost.org Asunto: [Boost-users] Boost::MultiIndex or std::map
Hi: I am in a situation where by I need to be able to query an associative container. I need to fill the container before querying. The key is an integer and the vlaue is a std::string. Can I construct boost::multiIndex so as to allow key/value pairs to be entered at construction time or should I just use std::map and write a function.
I'm not sure I'm getting your question, but certainly you can fill up
a std::map with key/value pairs before querying it!
std::map

Hi: Thanks for that, Can I fill a map up at construction withou using std::Map::Insert? Can I do this with Boost::MultiIndex? Sean. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of JOAQUIN M. LOPEZ MUÑOZ Sent: 06 June 2008 18:56 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Boost::MultiIndex or std::map Hi Sean, ________________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Sean Farrow [sean.farrow@seanfarrow.co.uk] Enviado el: viernes, 06 de junio de 2008 19:26 Para: boost-users@lists.boost.org Asunto: [Boost-users] Boost::MultiIndex or std::map
Hi: I am in a situation where by I need to be able to query an associative container. I need to fill the container before querying. The key is an integer and the vlaue is a std::string. Can I construct boost::multiIndex so as to allow key/value pairs to be entered at construction time or should I just use std::map and write a function.
I'm not sure I'm getting your question, but certainly you can fill up a std::map with key/value pairs before querying it!
std::map

std::map has a constructor which accepts iterator to the begin and the end
of the range being inserted at construction time. You can use them to insert
items at construction time.
Good Luck,
Ovanes
On Fri, Jun 6, 2008 at 8:35 PM, Sean Farrow
Hi: Thanks for that, Can I fill a map up at construction withou using std::Map::Insert? Can I do this with Boost::MultiIndex? Sean.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto: boost-users-bounces@lists.boost.org] On Behalf Of JOAQUIN M. LOPEZ MUÑOZ Sent: 06 June 2008 18:56 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Boost::MultiIndex or std::map
Hi Sean, ________________________________________ De: boost-users-bounces@lists.boost.org [ boost-users-bounces@lists.boost.org] En nombre de Sean Farrow [ sean.farrow@seanfarrow.co.uk] Enviado el: viernes, 06 de junio de 2008 19:26 Para: boost-users@lists.boost.org Asunto: [Boost-users] Boost::MultiIndex or std::map
Hi: I am in a situation where by I need to be able to query an associative container. I need to fill the container before querying. The key is an integer and the vlaue is a std::string. Can I construct boost::multiIndex so as to allow key/value pairs to be entered at construction time or should I just use std::map and write a function.
I'm not sure I'm getting your question, but certainly you can fill up a std::map with key/value pairs before querying it!
std::map
m; m.insert(std::make_pair(0,"zero")); m.insert(std::make_pair(1,"one")); ... m.find(1); What's it that you contend you can't do with a std::map but you can with a multi_index_container?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________ Information from ESET NOD32 Antivirus, version of virus signature database 3164 (20080606) __________
The message was checked by ESET NOD32 Antivirus.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 3164 (20080606) __________
The message was checked by ESET NOD32 Antivirus.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Ovanes Markarian wrote:
std::map has a constructor which accepts iterator to the begin and the end of the range being inserted at construction time. You can use them to insert items at construction time.
Then there's boost::assign::map_list_of()... http://www.boost.org/doc/libs/1_35_0/libs/assign/doc/index.html#map_list_of

Hi: Can I use this in dllMain? And can I set a map variable to null? Sean. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Nat Goodspeed Sent: 06 June 2008 21:34 To: boost-users@lists.boost.org Subject: [BULK] Re: [Boost-users] Boost::MultiIndex or std::map Importance: Low Ovanes Markarian wrote:
std::map has a constructor which accepts iterator to the begin and the
end of the range being inserted at construction time. You can use them
to insert items at construction time.
Then there's boost::assign::map_list_of()... http://www.boost.org/doc/libs/1_35_0/libs/assign/doc/index.html#map_list _of _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users __________ Information from ESET NOD32 Antivirus, version of virus signature database 3164 (20080606) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 3165 (20080606) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 3167 (20080609) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 3180 (20080612) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 3182 (20080612) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 3182 (20080612) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com

Sean Farrow escribió:
Hi: Can I use this in dllMain?
Hi Sean, I'm no Win32 expert but it seems to me the restrictions on code executed in DLL entry points do not interfere with the kind of operations performed by container initialization, unless the ctors and dtors of the elements contained already contain problematic code. Put another way: if using STL containers posed no problems in your dllMain routine, using Boost.MultiIndex and Boost.Assign will work also. Your best option, however, is to try and see.
And can I set a map variable to null?
What do you mean by setting a "variable to null"? This does not make sense in general in C++; some types of objects, like pointers, can be set to a null value, but I don't know how this relates to your question. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (5)
-
JOAQUIN M. LOPEZ MUÑOZ
-
joaquin@tid.es
-
Nat Goodspeed
-
Ovanes Markarian
-
Sean Farrow