summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qarraydata/simplevector.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qarraydata/simplevector.h')
-rw-r--r--tests/auto/corelib/tools/qarraydata/simplevector.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h
index f708fc12d1..c2568cf29c 100644
--- a/tests/auto/corelib/tools/qarraydata/simplevector.h
+++ b/tests/auto/corelib/tools/qarraydata/simplevector.h
@@ -302,6 +302,32 @@ public:
d->insert(where, first, last);
}
+ void erase(iterator first, iterator last)
+ {
+ if (first == last)
+ return;
+
+ const T *const begin = d->begin();
+ const T *const end = begin + d->size;
+
+ if (d.needsDetach()) {
+ SimpleVector detached(Data::allocate(
+ d->detachCapacity(size() - (last - first)),
+ d->detachFlags()));
+ if (first != begin)
+ detached.d->copyAppend(begin, first);
+ detached.d->copyAppend(last, end);
+ detached.swap(*this);
+
+ return;
+ }
+
+ if (last == end)
+ d->truncate(end - first);
+ else
+ d->erase(first, last);
+ }
+
void swap(SimpleVector &other)
{
qSwap(d, other.d);