Jump to content
  • Advertisement
Sign in to follow this  
Juliean

Question about 'map'

This topic is 3015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there,

I've got a (hopefully) simple question, what is the best way to go through all elements of that map:

map<int, CClass>

without knowing all the 'ints'?

What I was trying to do was:


// is filled with infos from another map
map<int, CClass> TempMap;

int Size = TempMap.size();

for(int i = 0; i < Size; i++)
{
CClass Temp = TempMap.begin();
TempMap.erase(TempMap.begin());

//do something with 'Temp'
}


My problem is just that begin() returns an iterator and I don't have any idea how to work with this. Can anyone pls help me? Or does anyone got even an better idea going through that map?

Share this post


Link to post
Share on other sites
Advertisement

for (map<int, CClass>::iterator it = TempMap.begin(), end = TempMap.end();
it != end; ++it) {
int key = it->first;
CClass value = it->second;
//...
}



Does that answer your question?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!