Jump to content
  • Advertisement

Archived

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

huffer59

SDL problem

This topic is 5244 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

list particleList; list::iterator i; for(i=particleList.begin(); i!=particleList.end(); i++) { updateParticle(//pointer to s_Particle structure); } The problem I have is i can''t find it anywhere how to get a pointer to the element that iterator is pointing at.

Share this post


Link to post
Share on other sites
Advertisement
1) STL not SDL

2) If your list contains pointers to the s_Particle class, just dereference the iterator [ *i ]. If it contains just normal instances of the s_Particle class, dereference the pointer and use the address operator to pass it as a pointer [ &(*i) ].

Share this post


Link to post
Share on other sites
As porthios asserted, think of a list iterator as a pointer to the templated type in the list.

Share this post


Link to post
Share on other sites
list<s_Particle> particleList;
list<s_Particle>::iterator i;

for(i=particleList.begin(); i!=particleList.end(); i++)
{
updateParticle( (*i) );

}


although if i were you (and i'm not...), i'd do this instead

list<s_Particle> particleList;
list<s_Particle>::iterator i;

for(i=particleList.begin(); i!=particleList.end(); i++)
{
(*i)->Update();

}



[edited by - leiavoia on June 10, 2004 8:12:22 PM]

Share this post


Link to post
Share on other sites
Also you should get into the habbit of preincrementing with STL wherever possible instead of post incrementing as it is more efficient with STL.

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!