C++ (Qt)QList<JobData>::iterator it = m_jobList.begin();while (it != m_jobList.end()) { if ((*it).state == JS_DONE) { m_jobList.removeOne(*it); } ++it;}
C++ (Qt)foreach (JobData jb, m_jobList) { if (jb.state == JS_DONE) m_jobList.removeAt(m_jobList.indexOf(jb));}
C++ (Qt)int i = 0;while (i < m_jobList.size()) { if (m_jobList[i].state == JS_DONE) m_jobList.removeAt(i); else ++i;}
C++ (Qt)#include <QtGui> template <class T, class TShouldDel>void QListRemoveIf( QList<T> & lst, TShouldDel shouldDel ){ int i = 0, last = lst.size(); while (i < last) { if (shouldDel(lst[i])) lst.swap(i, --last); else ++i; } lst.erase(lst.begin() + last, lst.end());} bool MyShouldDel( int val ){ return val == 1;} int main( void ) { QList <int> test; test << 2 << 3 << 1 << 9; qDebug() << test; QListRemoveIf(test, MyShouldDel); qDebug() << test; return 0;}
C++ (Qt)QList<JobData>::iterator it = m_jobList.begin();while (it != m_jobList.end()) { if ((*it).state == JS_DONE) it = m_jobList.erase(it); else ++it;}