Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::map question

Reply
Thread Tools

std::map question

 
 
Razmig K
Guest
Posts: n/a
 
      08-25-2003
Dear mates,

Is there an elegant way to ensure the existence of a certain key among
the keys of a map variable ?

Thank you.

//rk
 
Reply With Quote
 
 
 
 
Dave Theese
Guest
Posts: n/a
 
      08-25-2003

Could you please clarify the question a little further?

I'm tempted to say "just insert a pair that has the key you desire to be
present", but somehow I think that's probably missing your intended point...


"Razmig K" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Dear mates,
>
> Is there an elegant way to ensure the existence of a certain key among
> the keys of a map variable ?
>
> Thank you.
>
> //rk



 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      08-25-2003

Razmig K <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Dear mates,
>
> Is there an elegant way to ensure the existence of a certain key among
> the keys of a map variable ?


if(the_map.find(key) == the_map.end())
the_map[key];

-Mike



 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      08-25-2003
Razmig K wrote:

> Dear mates,
>
> Is there an elegant way to ensure the existence of a certain key among
> the keys of a map variable ?
>


I'm not sure I understand. If you want to make sure a certain key will
exist in the map, you need only insert it. As long as you don't remove
it later, this ensures that the key will exist "among the keys in the
map variable".

If you meant to ask how one would check for the existence of a
particular key, the answer is to use the 'find()' function.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments