Array-backed containers: add shrink_to_fit for STL compatibility
Side note: QHash has squeeze(), but there's no shrink_to_fit on std::unordered_map. [ChangeLog][QtCore][QByteArray] Added shrink_to_fit(). [ChangeLog][QtCore][QString] Added shrink_to_fit(). [ChangeLog][QtCore][QVarLengthArray] Added shrink_to_fit(). [ChangeLog][QtCore][QVector] Added shrink_to_fit(). Change-Id: Ifd7d28c9bed70727be6308f0191a188201784f61 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>bb10
parent
58a4f41af2
commit
9dff809b45
|
|
@ -1134,6 +1134,13 @@ static inline char qToLower(char c)
|
|||
Same as prepend(\a ch).
|
||||
*/
|
||||
|
||||
/*! \fn void QByteArray::shrink_to_fit()
|
||||
\since 5.10
|
||||
|
||||
This function is provided for STL compatibility. It is equivalent to
|
||||
squeeze().
|
||||
*/
|
||||
|
||||
/*! \fn QByteArray::QByteArray(const QByteArray &other)
|
||||
|
||||
Constructs a copy of \a other.
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ public:
|
|||
inline void push_front(char c);
|
||||
inline void push_front(const char *c);
|
||||
inline void push_front(const QByteArray &a);
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
static inline QByteArray fromStdString(const std::string &s);
|
||||
inline std::string toStdString() const;
|
||||
|
|
|
|||
|
|
@ -8469,6 +8469,15 @@ bool QString::isRightToLeft() const
|
|||
Appends the given \a ch character onto the end of this string.
|
||||
*/
|
||||
|
||||
/*! \fn void QString::shrink_to_fit()
|
||||
\since 5.10
|
||||
|
||||
This function is provided for STL compatibility. It is
|
||||
equivalent to squeeze().
|
||||
|
||||
\sa squeeze()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn std::string QString::toStdString() const
|
||||
|
||||
|
|
|
|||
|
|
@ -805,6 +805,7 @@ public:
|
|||
inline void push_back(const QString &s) { append(s); }
|
||||
inline void push_front(QChar c) { prepend(c); }
|
||||
inline void push_front(const QString &s) { prepend(s); }
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
static inline QString fromStdString(const std::string &s);
|
||||
inline std::string toStdString() const;
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ public:
|
|||
inline const T &front() const { return first(); }
|
||||
inline T &back() { return last(); }
|
||||
inline const T &back() const { return last(); }
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
private:
|
||||
void realloc(int size, int alloc);
|
||||
|
|
|
|||
|
|
@ -190,6 +190,12 @@
|
|||
\overload
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::shrink_to_fit()
|
||||
\since 5.10
|
||||
|
||||
Same as squeeze(). Provided for STL-compatibility.
|
||||
*/
|
||||
|
||||
/*! \fn bool QVarLengthArray::isEmpty() const
|
||||
|
||||
Returns \c true if the array has size 0; otherwise returns \c false.
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ public:
|
|||
inline const_reference front() const { return first(); }
|
||||
inline reference back() { return last(); }
|
||||
inline const_reference back() const { return last(); }
|
||||
void shrink_to_fit() { squeeze(); }
|
||||
|
||||
// comfort
|
||||
QVector<T> &operator+=(const QVector<T> &l);
|
||||
|
|
|
|||
|
|
@ -1124,6 +1124,13 @@
|
|||
\overload
|
||||
*/
|
||||
|
||||
/*! \fn void QVector::shrink_to_fit()
|
||||
\since 5.10
|
||||
|
||||
This function is provided for STL compatibility. It is equivalent
|
||||
to squeeze().
|
||||
*/
|
||||
|
||||
/*! \fn bool QVector::empty() const
|
||||
|
||||
This function is provided for STL compatibility. It is equivalent
|
||||
|
|
|
|||
Loading…
Reference in New Issue