本文整理汇总了C++中QList::isDetached方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::isDetached方法的具体用法?C++ QList::isDetached怎么用?C++ QList::isDetached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::isDetached方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeAll_test
void removeAll_test(const QList<int> &i10, ushort valueToRemove, int itemsToRemove)
{
bool isComplex = QTypeInfo<T>::isComplex;
MyBase::errorCount = 0;
MyBase::liveCount = 0;
MyBase::copyCount = 0;
{
QList<T> list;
QCOMPARE(MyBase::liveCount, 0);
QCOMPARE(MyBase::copyCount, 0);
for (int i = 0; i < 10 * N; ++i) {
T t(i10.at(i % 10));
list.append(t);
}
QCOMPARE(MyBase::liveCount, isComplex ? list.size() : 0);
QCOMPARE(MyBase::copyCount, isComplex ? list.size() : 0);
T t(valueToRemove);
QCOMPARE(MyBase::liveCount, isComplex ? list.size() + 1 : 1);
QCOMPARE(MyBase::copyCount, isComplex ? list.size() : 0);
int removedCount;
QList<T> l;
QBENCHMARK {
l = list;
removedCount = l.removeAll(t);
}
QCOMPARE(removedCount, itemsToRemove * N);
QCOMPARE(l.size() + removedCount, list.size());
QVERIFY(!l.contains(valueToRemove));
QCOMPARE(MyBase::liveCount, isComplex ? l.isDetached() ? list.size() + l.size() + 1 : list.size() + 1 : 1);
QCOMPARE(MyBase::copyCount, isComplex ? l.isDetached() ? list.size() + l.size() : list.size() : 0);
}
if (isComplex)
QCOMPARE(MyBase::errorCount, 0);
}