SDL problem
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.
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) ].
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) ].
As porthios asserted, think of a list iterator as a pointer to the templated type in the list.
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]
Also you should get into the habbit of preincrementing with STL wherever possible instead of post incrementing as it is more efficient with STL.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement