Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualSyerjchep

Posted 13 June 2013 - 08:42 PM

So right now I'm using alleightup's suggestion and it's working well. Hopefully there isn't any memory loss, it'll be a little bit before I have the actual program ready to test and can see for myself.
 
Currently my question is how can I remove an element?
Something along the lines of this:
 
for(auto& it : lifeforms)
{
      if(it->food < 1)
            lifeforms.remove(it);
}
Does not work.
The program crashes.

How do I remove an element?
(while freeing its memory, as I only need the elements that are in the list)

#2Syerjchep

Posted 13 June 2013 - 07:53 PM

So right now I'm using alleightup's suggestion and it's working well. Hopefully there isn't any memory loss, it'll be a little bit before I have the actual program ready to test and can see for myself.
 
Currently my question is how can I remove an element?
Something along the lines of this:
 
for(auto& it : lifeforms)
{
      if(it->food < 1)
            lifeforms.remove(it);
}
Does not work.
The program crashes.

How do I remove an element?

#1Syerjchep

Posted 13 June 2013 - 07:52 PM

So right now I'm using alleightup's suggestion and it's working well. Hopefully there isn't any memory loss, it'll be a little bit before I have the actual program ready to test and can see for myself.

 

Currently my question is how can I remove an element?

Something along the lines of this:

for(auto& it : lifeforms)
{
      if(it->food < 1)
            lifeforms.remove(it);
}

PARTNERS