Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Impz0r

std::list pass through from the end to the beginning...how?!

This topic is 6013 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, I''m trying to pass through my std::list from back to front (for rendering things), but i became an runtime error. I use the following code : list::iterator i = m_aChildControls.begin (); list::iterator End = m_aChildControls.end (); while (End != i) { (*End)->Render (); --End; } but i became in the first passageway the exception, but wenn i decrement the end iterator about one, then it works, but it draws not all controls, he lost the last (first) control. Did someone knows the correct why to do this ?! Thanks alot... Mfg Impz0r

Share this post


Link to post
Share on other sites
Advertisement
hmm, damn, no i haven''t read the whole doc, but it seams i have to do this, whatever thanks for your help :D

Mfg Impz0r

Share this post


Link to post
Share on other sites
*ahem*

list::reverse_iterator i = m_aChildControls.rbegin();
list::reverse_iterator end = m_aChildControls.rend();
while(i != End)
{
// you shouldn''t be fooling around with your end
// if you want to go in reverse order
(*i)->Render();
// you can increment reverse_iterators in "normal" fashion
++i;
}


[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites

  • 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!