From cc164f9ac73cd44a0ab082af78dccde8057154dc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 31 Mar 2015 00:14:24 +0200 Subject: QVarLengthArray: add {const_,reverse_iterator}, {c,}r{begin,end}() [ChangeLog][QtCore][QVarLengthArray] Added rbegin(), crbegin(), rend(), crend(), and reverse_iterator and const_reverse_iterator typedefs. Task-number: QTBUG-25919 Change-Id: Ifda5d420802a3594c3181f54036279f16a7da16e Reviewed-by: Thiago Macieira --- src/corelib/tools/qvarlengtharray.h | 9 +++++ src/corelib/tools/qvarlengtharray.qdoc | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 2d8f922cb8..2933e40549 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -45,6 +45,7 @@ #ifdef Q_COMPILER_INITIALIZER_LISTS #include #endif +#include QT_BEGIN_NAMESPACE @@ -165,6 +166,8 @@ public: typedef T* iterator; typedef const T* const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { return ptr; } inline const_iterator begin() const { return ptr; } @@ -174,6 +177,12 @@ public: inline const_iterator end() const { return ptr + s; } inline const_iterator cend() const { return ptr + s; } inline const_iterator constEnd() const { return ptr + s; } + reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } iterator insert(const_iterator before, int n, const T &x); inline iterator insert(const_iterator before, const T &x) { return insert(before, 1, x); } iterator erase(const_iterator begin, const_iterator end); diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 5533a7d663..1f3a73073f 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -459,6 +459,20 @@ Typedef for T *. Provided for STL compatibility. */ +/*! + \typedef QVarLengthArray::const_reverse_iterator + \since 5.6 + + Typedef for \c{std::reverse_iterator}. Provided for STL compatibility. +*/ + +/*! + \typedef QVarLengthArray::reverse_iterator + \since 5.6 + + Typedef for \c{std::reverse_iterator}. Provided for STL compatibility. +*/ + /*! \fn void QVarLengthArray::prepend(const T &value) \since 4.8 @@ -573,6 +587,52 @@ \sa constBegin(), end() */ +/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rbegin() + \since 5.6 + + Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first + item in the variable length array, in reverse order. + + \sa begin(), crbegin(), rend() +*/ + +/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rbegin() const + \since 5.6 + \overload +*/ + +/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crbegin() const + \since 5.6 + + Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first + item in the variable length array, in reverse order. + + \sa begin(), rbegin(), rend() +*/ + +/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rend() + \since 5.6 + + Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past + the last item in the variable length array, in reverse order. + + \sa end(), crend(), rbegin() +*/ + +/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rend() const + \since 5.6 + \overload +*/ + +/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crend() const + \since 5.6 + + Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one + past the last item in the variable length array, in reverse order. + + \sa end(), rend(), rbegin() +*/ + /*! \fn QVarLengthArray::iterator QVarLengthArray::erase(const_iterator pos) \since 4.8 -- cgit v1.2.3