diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2012-04-26 12:06:17 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-30 17:07:27 +0200 |
commit | d17cf14185eb84863549e0119c8b7bd20db78580 (patch) | |
tree | 843efdf2b591293fabf8c5a7cf448d9514f35495 /tests/benchmarks/corelib/tools/qvector/qrawvector.h | |
parent | 5131aefc1f0c04936e3ef19c9870d884775471e5 (diff) |
Implement QVector with QArrayData interface.
Change-Id: I109f46892aed2f6024459812d24922b12358814d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/benchmarks/corelib/tools/qvector/qrawvector.h')
-rw-r--r-- | tests/benchmarks/corelib/tools/qvector/qrawvector.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h index 18d9847c95..7d80c125ea 100644 --- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h +++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h @@ -47,6 +47,7 @@ #include <QtCore/qatomic.h> #include <QtCore/qalgorithms.h> #include <QtCore/qlist.h> +#include <QtCore/private/qtools_p.h> #include <iterator> #include <vector> @@ -59,7 +60,32 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +struct QVectorData +{ + QtPrivate::RefCount ref; + int size; + uint alloc : 31; + uint capacityReserved : 1; + + qptrdiff offset; + + void* data() { return reinterpret_cast<char *>(this) + this->offset; } + + static const QVectorData shared_null; + static QVectorData *allocate(int size, int alignment); + static QVectorData *reallocate(QVectorData *old, int newsize, int oldsize, int alignment); + static void free(QVectorData *data, int alignment); + static int grow(int sizeOfHeader, int size, int sizeOfT); +}; +template <typename T> +struct QVectorTypedData : QVectorData +{ + T* begin() { return reinterpret_cast<T *>(this->data()); } + T* end() { return begin() + this->size; } + + static QVectorTypedData *sharedNull() { return static_cast<QVectorTypedData *>(const_cast<QVectorData *>(&QVectorData::shared_null)); } +}; template <typename T> class QRawVector |