Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > map question - ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 45715 of 48022
Post > Topic >>

map question - need to find a string from an int but also need the int from the string?

by "Angus" <nospam@[EMAIL PROTECTED] > May 3, 2008 at 11:09 AM

I have a map between an integer value - call it a deviceID and a device
name - call it devicename.

If I use a map I can either use the int or the string as the key.  But
which?  If I use for example the deviceid as the key, then if I need to
find
the deviceID from the devicename then I need to iterate through the whole
map.  I am worried about performance of this.

I setup the map at program startup - and it is static.  So I wondered
about
haveing a map<string,int> and a map<int,string>.  But it doesn't seem so
elegant - although maybe most efficient way.

Are there any other way of me achieving my goal of high performance in
lookups both ways?

Angus
 




 5 Posts in Topic:
map question - need to find a string from an int but also need t
"Angus" <nos  2008-05-03 11:09:16 
Re: map question - need to find a string from an int but also ne
Pela <marco_pela@[EMAI  2008-05-03 12:33:58 
Re: map question - need to find a string from an int but also ne
Saeed Amrollahi <s_amr  2008-05-03 03:44:10 
Re: map question - need to find a string from an int but also ne
"Angus" <nos  2008-05-03 13:03:46 
Re: map question - need to find a string from an int but also ne
utab <umut.tabak@[EMAI  2008-05-03 07:27:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:31:21 CDT 2008.