Access to map data

Posted by herzl shemuelian on Stack Overflow See other posts from Stack Overflow or by herzl shemuelian
Published on 2011-02-14T15:22:05Z Indexed on 2011/02/14 15:25 UTC
Read the original article Hit count: 204

Filed under:
|
|

I have a complex map that defined

 typedef short short1
 typedef short short2
 typedef  map<short1,short2> data_list;
 typedef  map<string,list> table_list;

I have a class that fill table_list

class GroupingClass
{
    table_list m_table_list;
    string Buildkey(OD e1){
       string ostring;
       ostring+=string(e1.m_Date,sizeof(Date));
       ostring+=string(e1.m_CT,sizeof(CT));
       ostring+=string(e1.m_PT,sizeof(PT));
       return ostring;
   }
   void operator() (const  map<short1,short2>::value_type& myPair) {

       OptionsDefine e1=myPair.second;
       string key=Buildkey(e1);
       m_table_list[key][e1.m_short2]=e1.m_short2;
   }

   operator table_list() {
    return m_table_list;
   }
};

and I use it by

  table_list TL2    
  GroupingClass gc;
  TL2=for_each(mapOD.begin(), mapOD.end(), gc);

but when I try to access to internal map I have problems for example

 data_list tmp;
 tmp=TL2["AAAA"];
 short i=tmp[1]; //I dont update i variable

but if i use a loop by itrator this work properly why this no work at first way thanks herzl

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl