c++ - Inserting and Reading Values from 3D Map -



c++ - Inserting and Reading Values from 3D Map -

first of read asked questions related questions, didn't able solve problem. have 1 3d map,

map<int,map<const char*, const char*>> map3d; map<const char*, const char*> submap;

now inserted valued in this, max of value of int 5 each int value there 50 key , value submap.

i inserted value

submap.insert(std::pair<const char*,const char*>(tempa, tempb)); map3d.insert(pair<int,map<const char*,const char*>>(count,submap));

count value incremented after temp1 , tempb values more 50 values. want read values , doing mentioned in question how loop through c++ map.

std::map<int,map<const char*,const char*>>::iterator out_it; for(out_it =map3d.begin();out_it != map3d.end();++out_it) { for(std::map<const char*, const char*>::const_iterator in_it=out_it->second.begin();in_it != out_it->second.end(); ++in_it) std::cout << in_it->first << " => " << in_it->second <<endl; }

as int 5 showing 5 values of tempa , tempb. if iterate in submap, showing values

for(std::map<const char*, const char*>::const_iterator in_it=submap.begin();in_it != submap.end(); ++in_it) std::cout << in_it->first << " => " << in_it->second <<endl;

can guide me how can read values. thanks

everything correct. because code every time inserts same submap:

submap.insert(std::pair<const char*,const char*>(tempa, tempb)); map3d.insert(pair<int,map<const char*,const char*>>(count,submap));

if need submap contains values, need fill submap first , insert map3d or utilize pointer submap.

map<int,map<const char*, const char*>*> map3d; map<const char*, const char*>* submap = new map<const char*, const char*>(); ... submap->insert(std::pair<const char*,const char*>(tempa, tempb)); map3d.insert(pair<int,map<const char*,const char*>*>(count,submap));

otherwise need create submap each time when want insert map3d.

map<const char*, const char*> submap; submap.insert(std::pair<const char*,const char*>(tempa, tempb)); map3d.insert(pair<int,map<const char*,const char*>>(count,submap));

c++ map

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -