Hey.
if you want to get max speed out of this you could create a functionobject class that is
used in remove_if(); go with a object so you can pass other params to the class and not the predicate_function set up
this way you can process the whole list and at the same time remove any elements that meet you
criteria.
Its a bit of work but I think its worth it for some lists things
Here Some Thing Like This Here.
.
//-----------------------------------------------------------------------------------------
//this is our Function object used in remove_if we pass our self to
//we need to set the render values before passing in
//------------------------------------------------------------------------------------------
class cFunctionObject
{
public:
D3DXMATRIX *View;
D3DXMATRIX *Projection;
D3DXMATRIX *LightView;
D3DXMATRIX *LightVolume;
cFunctionObject(void)
{
}//end
/////////////////////////////////////////////////////////
~cFunctionObject(void)
{
}//end
////////////////////////////////////////////////////////////////
const cFunctionObject& cFunctionObject::operator=(const cFunctionObject& s)
{
View = s.View;
Projection = s.Projection;
LightView = s.LightView;
LightVolume = s.LightView;
return *this;
}
//----------------------------------------------------------------------------------------------------
//A function object, or functor, is any type that implements operator(). This operator is referred to as
//the call operator or sometimes the application operator. The Standard Template Library uses function
//objects primarily as sorting criteria for containers and in algorithms.
//you want all the testing for deleting element in here this gets call for each list item
//----------------------------------------------------------------------------------------------------
bool cFunctionObject::operator() (cDropPodSate &droppod) //droppod is what object type your list holds
{
//does list menrs update returns true to remove from the list
bool done = droppod.ProcessDropPod(mTerrain, *timedelta);
if(done == false)
{
D3DXMATRIX vp = (*View) * (*Projection);
D3DXMATRIX Scale, Rotation;
D3DXMATRIX World;
//render the pod
}//end render pod
return done;//if its true it gets removed
}//end operator()
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------
//must call it before using pass things need to the object
//----------------------------------------------------------------------------------------
void SetFunctionObject(D3DXMATRIX *view,
D3DXMATRIX *projection,
D3DXMATRIX *lightView,
D3DXMATRIX *lightVolume)
{
View = view;
Projection = projection;
LightView = lightView;
LightVolume = lightVolume;
}//end SetFunctionObject
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
};//end class cFunctionObject
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
And Used Like This.
.
//we are using a function object to pass to remove_if which will do the processing and remove them if function object returns true
//also in this cas does the rendering of the pod as well
cFunctionObject FunctionObject;
FunctionObject.SetFunctionObject(&View,
&Projection,
LightView,
LightVolume);
//the remove_if will go through the whole list and remove when pods process is true
DropPodsList.erase(std::remove_if(DropPodsList.begin(), .DropPodsList.end(), FunctionObject), DropPodsList.end());
and thats all there is Give it a try.