From 5957f245c6c77c98d7e90d614c9fe2cdbfe7e8e6 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 2 Sep 2012 15:41:59 +0200 Subject: Mark most of the contents of QtAlgorithms as deprecated. This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: Ic31c052e7f35c576250bf11826ca82e371142c82 Reviewed-by: Olivier Goffart Reviewed-by: Robin Burchell --- dist/changes-5.2.0 | 29 +++++ src/corelib/tools/qalgorithms.h | 94 +++++++++------- src/corelib/tools/qalgorithms.qdoc | 222 ++++++++++++++++++++++++++++--------- 3 files changed, 252 insertions(+), 93 deletions(-) diff --git a/dist/changes-5.2.0 b/dist/changes-5.2.0 index 5e984a41d8..54f809ae25 100644 --- a/dist/changes-5.2.0 +++ b/dist/changes-5.2.0 @@ -46,3 +46,32 @@ QtCore When calling QTime::toString(Qt::TextDate) and QTime::toString(Qt::ISODate), milliseconds are now included in the returned string. This also applies to QDateTime::toString(Qt::TextDate) and QDateTime::toString(ISODate). + +- QtAlgorithms + With STL no longer being optional for building and using Qt, a number of parts + of QtAlgorithms no longer make sense, and have therefore been deprecated. + + Replacements are available in the STL, and generally have much better + performance, but are not instantly source-compatible in all cases. For + instance, specialization of qLess or qSwap means that a direct port to + std::sort from qSort may not be possible, as std::sort does not use any of + them; a possible workaround is explicitly passing a qLess functor to + std::sort: + + std::sort(container.begin(), container.end(), qLess()); + + The functions in QtAlgorithms that have been deprecated, along with their + STL counterparts, are: + - qBinaryFind (std::binary_search / std::lower_bound) + - qCopy (std::copy) + - qCopyBackward (std::copy_backward) + - qEqual (std::equal) + - qFill (std::fill) + - qFind (std::find) + - qCount (std::count) + - qSort (std::sort) + - qStableSort (std::stable_sort) + - qLowerBound (std::lower_bound) + - qUpperBound (std::upper_bound) + - qLess (std::less) + - qGreater (std::greater) diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 8337afcb9d..c6eede05cb 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -53,27 +53,30 @@ QT_BEGIN_NAMESPACE */ namespace QAlgorithmsPrivate { +#if QT_DEPRECATED_SINCE(5, 2) template -Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan); +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan); template -inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy); +QT_DEPRECATED inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy); template -Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan); +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan); template -inline void qStableSortHelper(RandomAccessIterator, RandomAccessIterator, const T &); +QT_DEPRECATED inline void qStableSortHelper(RandomAccessIterator, RandomAccessIterator, const T &); template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan); +#endif // QT_DEPRECATED_SINCE(5, 2) } +#if QT_DEPRECATED_SINCE(5, 2) template -inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest) +QT_DEPRECATED inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest) { while (begin != end) *dest++ = *begin++; @@ -81,7 +84,7 @@ inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterat } template -inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest) +QT_DEPRECATED inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest) { while (begin != end) *--dest = *--end; @@ -89,7 +92,7 @@ inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 } template -inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) +QT_DEPRECATED inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) { for (; first1 != last1; ++first1, ++first2) if (!(*first1 == *first2)) @@ -98,20 +101,20 @@ inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 f } template -inline void qFill(ForwardIterator first, ForwardIterator last, const T &val) +QT_DEPRECATED inline void qFill(ForwardIterator first, ForwardIterator last, const T &val) { for (; first != last; ++first) *first = val; } template -inline void qFill(Container &container, const T &val) +QT_DEPRECATED inline void qFill(Container &container, const T &val) { qFill(container.begin(), container.end(), val); } template -inline InputIterator qFind(InputIterator first, InputIterator last, const T &val) +QT_DEPRECATED inline InputIterator qFind(InputIterator first, InputIterator last, const T &val) { while (first != last && !(*first == val)) ++first; @@ -119,13 +122,13 @@ inline InputIterator qFind(InputIterator first, InputIterator last, const T &val } template -inline typename Container::const_iterator qFind(const Container &container, const T &val) +QT_DEPRECATED inline typename Container::const_iterator qFind(const Container &container, const T &val) { return qFind(container.constBegin(), container.constEnd(), val); } template -inline void qCount(InputIterator first, InputIterator last, const T &value, Size &n) +QT_DEPRECATED inline void qCount(InputIterator first, InputIterator last, const T &value, Size &n) { for (; first != last; ++first) if (*first == value) @@ -133,7 +136,7 @@ inline void qCount(InputIterator first, InputIterator last, const T &value, Size } template -inline void qCount(const Container &container, const T &value, Size &n) +QT_DEPRECATED inline void qCount(const Container &container, const T &value, Size &n) { qCount(container.constBegin(), container.constEnd(), value, n); } @@ -150,7 +153,7 @@ LessThan qGreater() } #else template -class qLess +class QT_DEPRECATED qLess { public: inline bool operator()(const T &t1, const T &t2) const @@ -160,7 +163,7 @@ public: }; template -class qGreater +class QT_DEPRECATED qGreater { public: inline bool operator()(const T &t1, const T &t2) const @@ -171,21 +174,21 @@ public: #endif template -inline void qSort(RandomAccessIterator start, RandomAccessIterator end) +QT_DEPRECATED inline void qSort(RandomAccessIterator start, RandomAccessIterator end) { if (start != end) QAlgorithmsPrivate::qSortHelper(start, end, *start); } template -inline void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) +QT_DEPRECATED inline void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) { if (start != end) QAlgorithmsPrivate::qSortHelper(start, end, *start, lessThan); } template -inline void qSort(Container &c) +QT_DEPRECATED inline void qSort(Container &c) { #ifdef Q_CC_BOR // Work around Borland 5.5 optimizer bug @@ -196,21 +199,21 @@ inline void qSort(Container &c) } template -inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end) +QT_DEPRECATED inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end) { if (start != end) QAlgorithmsPrivate::qStableSortHelper(start, end, *start); } template -inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) +QT_DEPRECATED inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) { if (start != end) QAlgorithmsPrivate::qStableSortHelper(start, end, *start, lessThan); } template -inline void qStableSort(Container &c) +QT_DEPRECATED inline void qStableSort(Container &c) { #ifdef Q_CC_BOR // Work around Borland 5.5 optimizer bug @@ -221,7 +224,7 @@ inline void qStableSort(Container &c) } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) { // Implementation is duplicated from QAlgorithmsPrivate to keep existing code // compiling. We have to allow using *begin and value with different types, @@ -244,19 +247,19 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { return QAlgorithmsPrivate::qLowerBoundHelper(begin, end, value, lessThan); } template -Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qLowerBound(const Container &container, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qLowerBound(const Container &container, const T &value) { return QAlgorithmsPrivate::qLowerBoundHelper(container.constBegin(), container.constEnd(), value, qLess()); } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) { // Implementation is duplicated from QAlgorithmsPrivate. RandomAccessIterator middle; @@ -277,19 +280,19 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { return QAlgorithmsPrivate::qUpperBoundHelper(begin, end, value, lessThan); } template -Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qUpperBound(const Container &container, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qUpperBound(const Container &container, const T &value) { return QAlgorithmsPrivate::qUpperBoundHelper(container.constBegin(), container.constEnd(), value, qLess()); } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) { // Implementation is duplicated from QAlgorithmsPrivate. RandomAccessIterator it = qLowerBound(begin, end, value); @@ -301,16 +304,17 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { return QAlgorithmsPrivate::qBinaryFindHelper(begin, end, value, lessThan); } template -Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qBinaryFind(const Container &container, const T &value) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qBinaryFind(const Container &container, const T &value) { return QAlgorithmsPrivate::qBinaryFindHelper(container.constBegin(), container.constEnd(), value, qLess()); } +#endif // QT_DEPRECATED_SINCE(5, 2) template Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end) @@ -333,8 +337,10 @@ inline void qDeleteAll(const Container &c) */ namespace QAlgorithmsPrivate { +#if QT_DEPRECATED_SINCE(5, 2) + template -Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan) { top: int span = int(end - start); @@ -387,13 +393,13 @@ top: } template -inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy) +QT_DEPRECATED inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy) { qSortHelper(begin, end, dummy, qLess()); } template -Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessIterator end) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessIterator end) { --end; while (begin < end) @@ -401,7 +407,7 @@ Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessItera } template -Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end) { qReverse(begin, middle); qReverse(middle, end); @@ -409,7 +415,7 @@ Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterat } template -Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, T &t, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, T &t, LessThan lessThan) { const int len1 = pivot - begin; const int len2 = end - pivot; @@ -444,7 +450,7 @@ Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterato } template -Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &t, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &t, LessThan lessThan) { const int span = end - begin; if (span < 2) @@ -457,13 +463,13 @@ Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAc } template -inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy) +QT_DEPRECATED inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy) { qStableSortHelper(begin, end, dummy, qLess()); } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { RandomAccessIterator middle; int n = int(end - begin); @@ -484,7 +490,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { RandomAccessIterator middle; int n = end - begin; @@ -504,7 +510,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator } template -Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) +QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) { RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan); @@ -514,6 +520,8 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator return it; } +#endif // QT_DEPRECATED_SINCE(5, 2) + } //namespace QAlgorithmsPrivate diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc index f3dfddec77..fce65b9a87 100644 --- a/src/corelib/tools/qalgorithms.qdoc +++ b/src/corelib/tools/qalgorithms.qdoc @@ -33,42 +33,18 @@ \brief The header includes the generic, template-based algorithms. Qt provides a number of global template functions in \c - that work on containers and perform well-known - algorithms. You can use these algorithms with any \l {container + that work on containers and perform small tasks to + make life easier, such as qDeleteAll(), which invokes \c{operator delete} + on all items in a given container or in a given range. + You can use these algorithms with any \l {container class} that provides STL-style iterators, including Qt's QList, QLinkedList, QVector, QMap, and QHash classes. - These functions have taken their inspiration from similar - functions available in the STL \c header. Most of them - have a direct STL equivalent; for example, qCopyBackward() is the - same as STL's copy_backward() algorithm. - - If STL is available on all your target platforms, you can use the - STL algorithms instead of their Qt counterparts. One reason why - you might want to use the STL algorithms is that STL provides - dozens and dozens of algorithms, whereas Qt only provides the most - important ones, making no attempt to duplicate functionality that - is already provided by the C++ standard. - Most algorithms take \l {STL-style iterators} as parameters. The algorithms are generic in the sense that they aren't bound to a specific iterator class; you can use them with any iterators that meet a certain set of requirements. - Let's take the qFill() algorithm as an example. Unlike QVector, - QList has no fill() function that can be used to fill a list with - a particular value. If you need that functionality, you can use - qFill(): - - \snippet code/doc_src_qalgorithms.cpp 0 - - qFill() takes a begin iterator, an end iterator, and a value. - In the example above, we pass \c list.begin() and \c list.end() - as the begin and end iterators, but this doesn't have to be - the case: - - \snippet code/doc_src_qalgorithms.cpp 1 - Different algorithms can have different requirements for the iterators they accept. For example, qFill() accepts two \l {forward iterators}. The iterator types required are specified @@ -78,15 +54,12 @@ necessarily a very informative one. Some algorithms have special requirements on the value type - stored in the containers. For example, qEqual() requires that the - value type supports operator==(), which it uses to compare items. - Similarly, qDeleteAll() requires that the value type is a + stored in the containers. For example, + qDeleteAll() requires that the value type is a non-const pointer type (for example, QWidget *). The value type requirements are specified for each algorithm, and the compiler will produce an error if a requirement isn't met. - \target binaryFind example - The generic algorithms can be used on other container classes than those provided by Qt and STL. The syntax of STL-style iterators is modeled after C++ pointers, so it's possible to use @@ -171,11 +144,95 @@ QList and QVector's non-const iterator types are random access iterators. + \section1 Qt and the STL algorithms + + Historically, Qt used to provide functions which were direct equivalents of + many STL algorithmic functions. Starting with Qt 5.0, you are instead + encouraged to use directly the implementations available in the STL; most + of the Qt ones have been deprecated (although they are still available to + keep the old code compiling). + + \section2 Porting guidelines + + Most of the times, an application using the deprecated Qt algorithmic functions + can be easily ported to use the equivalent STL functions. You need to + + \list 1 + \li add the \c{#include } preprocessor directive; + \li replace the Qt functions with the STL counterparts, according to the table below. + \endlist + + \table + \header + \li Qt function + \li STL function + \row + \li qBinaryFind + \li std::binary_search or std::lower_bound + \row + \li qCopy + \li std::copy + \row + \li qCopyBackward + \li std::copy_backward + \row + \li qEqual + \li std::equal + \row + \li qFill + \li std::fill + \row + \li qFind + \li std::find + \row + \li qCount + \li std::count + \row + \li qSort + \li std::sort + \row + \li qStableSort + \li std::stable_sort + \row + \li qLowerBound + \li std::lower_bound + \row + \li qUpperBound + \li std::upper_bound + \row + \li qLess + \li std::less + \row + \li qGreater + \li std::greater + + \endtable + + The only cases in which the port may not be straightforward is if the old + code relied on template specializations of the qLess() and/or the qSwap() + functions, which were used internally by the implementations of the Qt + algorithmic functions, but are instead ignored by the STL ones. + + In case the old code relied on the specialization of the qLess() functor, + then a workaround is explicitly passing an instance of the qLess() class + to the STL function, for instance like this: + + \code + std::sort(container.begin(), container.end(), qLess()); + \endcode + + Instead, since it's not possible to pass a custom swapper functor to STL + functions, the only workaround for a template specialization for qSwap() is + providing the same specialization for std::swap(). + \sa {container classes}, */ /*! \fn OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2) \relates + \obsolete + + Use std::copy instead. Copies the items from range [\a begin1, \a end1) to range [\a begin2, ...), in the order in which they appear. @@ -192,6 +249,9 @@ /*! \fn BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2) \relates + \obsolete + + Use std::copy_backward instead. Copies the items from range [\a begin1, \a end1) to range [..., \a end2). @@ -208,6 +268,9 @@ /*! \fn bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2) \relates + \obsolete + + Use std::equal instead. Compares the items in the range [\a begin1, \a end1) with the items in the range [\a begin2, ...). Returns true if all the @@ -224,6 +287,9 @@ /*! \fn void qFill(ForwardIterator begin, ForwardIterator end, const T &value) \relates + \obsolete + + Use std::fill instead. Fills the range [\a begin, \a end) with \a value. @@ -235,14 +301,19 @@ /*! \fn void qFill(Container &container, const T &value) \relates - + \obsolete \overload + Use std::fill instead. + This is the same as qFill(\a{container}.begin(), \a{container}.end(), \a value); */ /*! \fn InputIterator qFind(InputIterator begin, InputIterator end, const T &value) \relates + \obsolete + + Use std::find instead. Returns an iterator to the first occurrence of \a value in a container in the range [\a begin, \a end). Returns \a end if \a @@ -263,14 +334,19 @@ /*! \fn void qFind(const Container &container, const T &value) \relates - + \obsolete \overload + Use std::find instead. + This is the same as qFind(\a{container}.constBegin(), \a{container}.constEnd(), value); */ /*! \fn void qCount(InputIterator begin, InputIterator end, const T &value, Size &n) \relates + \obsolete + + Use std::count instead. Returns the number of occurrences of \a value in the range [\a begin, \a end), which is returned in \a n. \a n is never initialized, the count is added to \a n. @@ -287,17 +363,22 @@ */ /*! \fn void qCount(const Container &container, const T &value, Size &n) -\relates + \relates + \obsolete + \overload -\overload + Use std::count instead. -Instead of operating on iterators, as in the other overload, this function -operates on the specified \a container to obtain the number of instances -of \a value in the variable passed as a reference in argument \a n. + Instead of operating on iterators, as in the other overload, this function + operates on the specified \a container to obtain the number of instances + of \a value in the variable passed as a reference in argument \a n. */ /*! \fn void qSwap(T &var1, T &var2) \relates + \obsolete + + Use std::swap instead. Exchanges the values of variables \a var1 and \a var2. @@ -307,6 +388,9 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end) \relates + \obsolete + + Use std::sort instead. Sorts the items in range [\a begin, \a end) in ascending order using the quicksort algorithm. @@ -329,9 +413,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) \relates - + \obsolete \overload + Use std::sort instead. + Uses the \a lessThan function instead of \c operator<() to compare the items. @@ -363,15 +449,20 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qSort(Container &container) \relates - + \obsolete \overload + Use std::sort instead. + This is the same as qSort(\a{container}.begin(), \a{container}.end()); */ /*! \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end) \relates + \obsolete + + Use std::stable_sort instead. Sorts the items in range [\a begin, \a end) in ascending order using a stable sorting algorithm. @@ -396,9 +487,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan) \relates - + \obsolete \overload + Use std::stable_sort instead. + Uses the \a lessThan function instead of \c operator<() to compare the items. @@ -426,14 +519,19 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qStableSort(Container &container) \relates - + \obsolete \overload + Use std::stable_sort instead. + This is the same as qStableSort(\a{container}.begin(), \a{container}.end()); */ /*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) \relates + \obsolete + + Use std::lower_bound instead. Performs a binary search of the range [\a begin, \a end) and returns the position of the first ocurrence of \a value. If no @@ -460,9 +558,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) \relates - + \obsolete \overload + Use std::lower_bound instead. + Uses the \a lessThan function instead of \c operator<() to compare the items. @@ -473,9 +573,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qLowerBound(const Container &container, const T &value) \relates - + \obsolete \overload + Use std::lower_bound instead. + For read-only iteration over containers, this function is broadly equivalent to qLowerBound(\a{container}.begin(), \a{container}.end(), value). However, since it returns a const iterator, you cannot use it to modify the container; for example, @@ -484,6 +586,9 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) \relates + \obsolete + + Use std::upper_bound instead. Performs a binary search of the range [\a begin, \a end) and returns the position of the one-past-the-last occurrence of \a @@ -510,9 +615,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) \relates - + \obsolete \overload + Use std::upper_bound instead. + Uses the \a lessThan function instead of \c operator<() to compare the items. @@ -523,15 +630,20 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qUpperBound(const Container &container, const T &value) \relates - + \obsolete \overload + Use std::upper_bound instead. + This is the same as qUpperBound(\a{container}.begin(), \a{container}.end(), value); */ /*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value) \relates + \obsolete + + Use std::binary_search or std::lower_bound instead. Performs a binary search of the range [\a begin, \a end) and returns the position of an occurrence of \a value. If there are @@ -558,9 +670,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan) \relates - + \obsolete \overload + Use std::binary_search or std::lower_bound instead. + Uses the \a lessThan function instead of \c operator<() to compare the items. @@ -571,9 +685,11 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn void qBinaryFind(const Container &container, const T &value) \relates - + \obsolete \overload + Use std::binary_search or std::lower_bound instead. + This is the same as qBinaryFind(\a{container}.begin(), \a{container}.end(), value); */ @@ -612,6 +728,9 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn LessThan qLess() \relates + \obsolete + + Use std::less instead. Returns a functional object, or functor, that can be passed to qSort() or qStableSort(). @@ -625,6 +744,9 @@ of \a value in the variable passed as a reference in argument \a n. /*! \fn LessThan qGreater() \relates + \obsolete + + Use std::greater instead. Returns a functional object, or functor, that can be passed to qSort() or qStableSort(). -- cgit v1.2.3