Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Problems with std::map.insert() and std::map.find()

Reply
Thread Tools

Re: Problems with std::map.insert() and std::map.find()

 
 
acehreli@gmail.com
Guest
Posts: n/a
 
      12-21-2008
On Dec 19, 6:45*pm, "(2b|!2b)==?" <(E-Mail Removed)> wrote:

> template<class T1, class T2>
> class PointerMap


> class RepositoryKey


Could you please also show how you use these classes. Especially a few
lines of code that demonstrates the problem...

Ali
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      12-21-2008
(2b|!2b)==? wrote:
> http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>> On Dec 19, 6:45 pm, "(2b|!2b)==?" <(E-Mail Removed)> wrote:
>>
>>> template<class T1, class T2>
>>> class PointerMap

>>
>>> class RepositoryKey

>>
>> Could you please also show how you use these classes. Especially a few
>> lines of code that demonstrates the problem...
>>
>> Ali

>
> A snippet of how I am using the classes:
>
>
>
> void foobar(Rows& rows)
> {
> typedef PointerMap<RepositoryKey, MyValueClass> DataDictonary ;
> MyValueClass * myValue = 0;
> long xch, ic, fq ;
> std::string symb;
> MyDataRowIterator it = rows.begin();
>
> for (; it != rows.end(); ++it)
> {
> xch = (*it).xch;
> ic = (*it).ic;
> symb = (*it).symb ;
> fq = (*it).fq;
>
> //Does this 4-tuple exist in repository?
> RepositoryKey key(xch, ic, symb, fq);
> DataDictonary::iterator iter ;
>
> //NOTE: find() only works for first item inserted, so I have to
> //resort to manually iterating through all of the items in the map
> //and doing a comparison .... (the code below is how I want to
> use it though ...)
> if ( ( iter = dictionary.find()) != dictionary.end() )


dictionary.find() what?

> myValue = (*iter).second ;
> else
> {
> //create a new value for this key
> if ( (myValue = CreateValue()) )
> {
> //Now store the data in the dictionary
> //NOTE: Only the first insert works !
> dictionary.insert(key, myValue);
> }
> else
> throw std::bad_alloc();
> }
>
> // Do something with the value ....
> }
> }

 
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
Saving the web, charset problems and symbols problems Sak Na rede Ruby 0 01-30-2009 05:05 AM
Problems, problems for newbie Shelly ASP .Net 1 09-03-2007 02:10 AM
Problems compiling simple C++ code (also problems with std::string) Susan Baker C++ 2 06-26-2005 01:43 AM
Problems with opening new window without scrollbar and toolbar and with smaller size and width Jerry Manner HTML 2 05-30-2005 03:27 PM
Re: sound problems and modem problems Harold Potter Computer Support 5 12-04-2003 04:12 PM



Advertisments