PlotLine * SINWAV::calculateCustom (QString &, Q3PtrList<PlotLine> &) { Q3PtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getSINWAV(pll); pll.remove(1); return pll.at(0); }
void CppRefType::remove(UmlClass * cl, Q3PtrList<CppRefType> & l) { Q3PtrListIterator<CppRefType> it(l); for (; it.current(); ++it) { if ((*it)->type.type == cl) { l.remove(it); return; } } }
void CppRefType::remove(const WrapperStr & t, Q3PtrList<CppRefType> & l) { Q3PtrListIterator<CppRefType> it(l); for (; it.current(); ++it) { if ((*it)->type.explicit_type == t) { delete *it; l.remove(it); return; } } }
void tst_Q3PtrList::removeType() { Q3PtrList<QString> items; items.append(new QString("first")); QString *second = new QString("second"); items.append(second); QString *third = new QString("third"); items.append(third); QString *fourth = new QString("fourth"); items.append(fourth); QVERIFY(items.current() == fourth); items.setAutoDelete(FALSE); // this test an undocumented feature of remove( NULL ) // in QGList::remove if the ptr is 0 it removes the current item // ie. it removes the fourth item from the list in this case QString *nullPointer = NULL; items.remove( nullPointer ); QVERIFY(items.count() == 3); QVERIFY(items.current() == third); // this tests that remove updates the current item also // when it removes the _end_ item in the list items.remove(third); QVERIFY(items.current() == second); // test that the removed items are not in the list, then deletes them QVERIFY(third && items.find(third) == -1 ); QVERIFY(fourth && items.find(fourth) == -1); delete third; delete fourth; fourth = third = 0; items.setAutoDelete(TRUE); }