By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

map<,> optimization question

P: n/a
Hi,

I need use map faster as possible (I store in the map data about open
network connections).

First a question, this code fragment is from "The C++ Programming........
3rd edition by B. Stroustrup"

m[k] is equivalent to (*(m.insert(make_pair(k,V()))).first)).second

The work of V() is to create a void base tape? if so, the expression:

m.insert(make_pair(k,objItem))

where objItem is my object is a better choice?

thanks

Marco C.

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mcassiani wrote:
I need use map faster as possible (I store in the map data about open
network connections).

First a question, this code fragment is from "The C++ Programming........
3rd edition by B. Stroustrup"

m[k] is equivalent to (*(m.insert(make_pair(k,V()))).first)).second

The work of V() is to create a void base tape? if so, the expression:
Right.
m.insert(make_pair(k,objItem))

where objItem is my object is a better choice?


Could be. You won't know until you actually put it into the working
program and run it under a profiler. Speculation costs very little and
has no real value. Get results from timing your process, then judge.

V
Jul 23 '05 #2

P: n/a
Thanks for quick reply.
Jul 23 '05 #3

P: n/a

mcassiani wrote:
Hi,

I need use map faster as possible (I store in the map data about open
network connections).


These days, memory tends to be a lot faster than I/O. Usually, the
overhead of map will be insignificant. Just make sure the objects in
the map don't perform too much I/O - i.e. cheap default ctors.

HTH,
Michiel Salters

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.