diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-02-16 20:20:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-07 06:13:06 +0100 |
commit | ab52e722926d495e29263e59a466ad5ff0106275 (patch) | |
tree | 75bb1f0b3e408b20f944b325b6c55141eb2829cd /src/corelib/tools/qvector.h | |
parent | 510660080de6fab87e117de2663c33eff5ae451b (diff) |
QVector - add functions takeFirst and takeLast
This patch adds takeFirst and takeLast which are functions
that QList also has.
Change-Id: I761f90b529774edc8fa96e07c6fcf76226123b20
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r-- | src/corelib/tools/qvector.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index f6fe316a15..e2c28e4060 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -140,6 +140,8 @@ public: void remove(int i, int n); inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(d->begin()); } inline void removeLast() { Q_ASSERT(!isEmpty()); erase(d->end() - 1); } + inline T takeFirst() { Q_ASSERT(!isEmpty()); T r = first(); removeFirst(); return r; } + inline T takeLast() { Q_ASSERT(!isEmpty()); T r = last(); removeLast(); return r; } QVector<T> &fill(const T &t, int size = -1); |