home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,679 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: remove   
   21 Nov 11 14:20:51   
   
   7c653f24   
   From: daniel.kruegler@googlemail.com   
      
   Am 21.11.2011 19:13, schrieb bob:   
   > What is the best way to convert this to C++?  I'm concerned about the   
   > lack of iterator remove:   
   >   
   >          for (iterator  i = particles.iterator();   
   > i.hasNext();) {   
   >              final Particle p = i.next();   
   >              p.move();   
   >              p.timeleft--;   
   >   
   >              if (p.timeleft == 0) {   
   >                  i.remove();   
   >              }   
   >          }   
      
   C++ iterators don't allow this without any container or at least with   
   some further "remover" abstraction. Given one of the sequence,   
   associative, or unordered container classes, you would call the member   
   function erase with the iterator value as argument.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca