I'm quite happy with
Java's
ArrayList<String> list = new ArrayList<>();
Iterator<SignalEvent> it = list.iterator();
while (it.hasNext()) {
String s = it.next();
if(s.equals("delete me")){
it.remove();
}
}
std::list<MyObject*> mylist;
for (list<MyObject*>::iterator it = mylist.begin(); it != mylist.end();)
{
MyObject* se = (*it);
if(se->bDelete == true)
it = mylist.erase(it);
else
it++;
}
for( int i = arrayList.Count - 1; i >= 0; i -- )
{
if( arrayList[ i ].ToString() == "del" )
{
arrayList.RemoveAt( i );
}
}
If you don't mind creating a new list, you can use Linq, which is unquestionably graceful:
arrayList.where(x => x.toString() != "del");
Or if you still want to remove things from the list instead of using the previous solution, see if you can use a lambda expression instead:
arrayList.RemoveAll(x => x.toString() == "del");