summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qvector.cpp24
-rw-r--r--src/corelib/tools/qvector.h6
2 files changed, 26 insertions, 4 deletions
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index efc4b6a446..5ece011f0b 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -544,6 +544,26 @@
\sa insert(), replace(), fill()
*/
+/*! \fn void QVector::removeFirst()
+ \since 5.1
+ Removes the first item in the vector. Calling this function is
+ equivalent to calling remove(0). The vector must not be empty. If
+ the vector can be empty, call isEmpty() before calling this
+ function.
+
+ \sa remove(), isEmpty()
+*/
+
+/*! \fn void QVector::removeLast()
+ \since 5.1
+ Removes the last item in the vector. Calling this function is
+ equivalent to calling remove(size() - 1). The vector must not be
+ empty. If the vector can be empty, call isEmpty() before calling
+ this function.
+
+ \sa remove(), removeFirst(), isEmpty()
+*/
+
/*! \fn QVector &QVector::fill(const T &value, int size = -1)
Assigns \a value to all items in the vector. If \a size is
@@ -773,13 +793,13 @@
/*! \fn void QVector::pop_front()
This function is provided for STL compatibility. It is equivalent
- to erase(begin()).
+ to removeFirst().
*/
/*! \fn void QVector::pop_back()
This function is provided for STL compatibility. It is equivalent
- to erase(end() - 1).
+ to removeLast().
*/
/*! \fn T& QVector::front()
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 7d5cf91324..f6fe316a15 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -138,6 +138,8 @@ public:
void replace(int i, const T &t);
void remove(int i);
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); }
QVector<T> &fill(const T &t, int size = -1);
@@ -198,8 +200,8 @@ public:
typedef int size_type;
inline void push_back(const T &t) { append(t); }
inline void push_front(const T &t) { prepend(t); }
- void pop_back() { Q_ASSERT(!isEmpty()); erase(d->end() - 1); }
- void pop_front() { Q_ASSERT(!isEmpty()); erase(d->begin()); }
+ void pop_back() { removeLast(); }
+ void pop_front() { removeFirst(); }
inline bool empty() const
{ return d->size == 0; }
inline T& front() { return first(); }