Is there a better way to remove something from the middle (well, a general position) of a vector than this:
1 2 3 4 5 6 7 8 9 10 11
|
void RemoveSprite(int ref){
delete SpriteList[ref];
SpriteList[ref] = NULL;
vector<Sprite*>::iterator i;
for(i=SpriteList.begin(); i<SpriteList.end(); i++){
if(*i == NULL){
SpriteList.erase(i);
break;
}
}
}
|
Where SpriteList is a global vector of pointers to Sprite?
Last edited on
Oh, I didn't realise you could just add an integer on to the iterator like that.
Thankyou