From 5023c0beb52eed82e1e8ed1680878d2f7e0f693a Mon Sep 17 00:00:00 2001 From: Marcel Krems Date: Mon, 24 Aug 2020 17:20:18 +0200 Subject: Remove deprecated algorithms from documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie1eff48696c62ed23fedda1a9e711aeb8264432f Reviewed-by: Topi Reiniƶ --- .../doc/snippets/code/doc_src_qalgorithms.cpp | 303 +-------------------- src/corelib/tools/qalgorithms.qdoc | 23 +- 2 files changed, 7 insertions(+), 319 deletions(-) diff --git a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp index 58f6b196b4..6e4df4a912 100644 --- a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp @@ -49,316 +49,19 @@ ****************************************************************************/ //! [0] -QStringList list; -list << "one" << "two" << "three"; - -qFill(list.begin(), list.end(), "eleven"); -// list: [ "eleven", "eleven", "eleven" ] -//! [0] - - -//! [1] -qFill(list.begin() + 1, list.end(), "six"); -// list: [ "eleven", "six", "six" ] -//! [1] - - -//! [2] -QChar resolveEntity(const QString &entity) -{ - static const QLatin1String name_table[] = { - "AElig", "Aacute", ..., "zwnj" - }; - static const ushort value_table[] = { - 0x0061, 0x00c1, ..., 0x200c - }; - int N = sizeof(name_table) / sizeof(name_table[0]); - - const QLatin1String *name = qBinaryFind(name_table, name_table + N, - entity); - int index = name - name_table; - if (index == N) - return QChar(); - - return QChar(value_table[index]); -} -//! [2] - - -//! [3] -QChar resolveEntity(const QString &entity) -{ - static QMap entityMap; - - if (!entityMap) { - entityMap.insert("AElig", 0x0061); - entityMap.insert("Aacute", 0x00c1); - ... - entityMap.insert("zwnj", 0x200c); - } - return QChar(entityMap.value(entity)); -} -//! [3] - - -//! [4] -QStringList list; -list << "one" << "two" << "three"; - -QList list1(3); -qCopy(list.begin(), list.end(), list1.begin()); -// list1: [ "one", "two", "three" ] - -QList list2(8); -qCopy(list.begin(), list.end(), list2.begin() + 2); -// list2: [ "", "", "one", "two", "three", "", "", "" ] -//! [4] - - -//! [5] -QStringList list; -list << "one" << "two" << "three"; - -QList backList(5); -qCopyBackward(list.begin(), list.end(), backList.end()); -// backList: [ "", "", "one", "two", "three" ] -//! [5] - - -//! [6] -QStringList listLeft; -listLeft << "one" << "two" << "three"; - -QList listRight(3); -listRight[0] = "one"; -listRight[1] = "two"; -listRight[2] = "three"; - -bool ret1 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin()); -// ret1 == true - -listRight[2] = "seven"; -bool ret2 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin()); -// ret2 == false -//! [6] - - -//! [7] -QStringList list; -list << "one" << "two" << "three"; - -qFill(list.begin(), list.end(), "eleven"); -// list: [ "eleven", "eleven", "eleven" ] - -qFill(list.begin() + 1, list.end(), "six"); -// list: [ "eleven", "six", "six" ] -//! [7] - - -//! [8] -QStringList list; -list << "one" << "two" << "three"; - -QStringList::iterator i1 = qFind(list.begin(), list.end(), "two"); -// i1 == list.begin() + 1 - -QStringList::iterator i2 = qFind(list.begin(), list.end(), "seventy"); -// i2 == list.end() -//! [8] - - -//! [9] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; - -int countOf6 = 0; -qCount(list.begin(), list.end(), 6, countOf6); -// countOf6 == 3 - -int countOf7 = 0; -qCount(list.begin(), list.end(), 7, countOf7); -// countOf7 == 0 -//! [9] - - -//! [10] double pi = 3.14; double e = 2.71; qSwap(pi, e); // pi == 2.71, e == 3.14 -//! [10] - - -//! [11] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qSort(list.begin(), list.end()); -// list: [ 6, 12, 12, 33, 68 ] -//! [11] - - -//! [12] -bool caseInsensitiveLessThan(const QString &s1, const QString &s2) -{ - return s1.toLower() < s2.toLower(); -} - -int doSomething() -{ - QStringList list; - list << "AlPha" << "beTA" << "gamma" << "DELTA"; - qSort(list.begin(), list.end(), caseInsensitiveLessThan); - // list: [ "AlPha", "beTA", "DELTA", "gamma" ] -} -//! [12] - - -//! [13] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qSort(list.begin(), list.end(), qGreater()); -// list: [ 68, 33, 12, 12, 6 ] -//! [13] - - -//! [14] -QStringList list; -list << "AlPha" << "beTA" << "gamma" << "DELTA"; - -QMap map; -foreach (const QString &str, list) - map.insert(str.toLower(), str); - -list = map.values(); -//! [14] - - -//! [15] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qStableSort(list.begin(), list.end()); -// list: [ 6, 12, 12, 33, 68 ] -//! [15] - - -//! [16] -bool caseInsensitiveLessThan(const QString &s1, const QString &s2) -{ - return s1.toLower() < s2.toLower(); -} - -int doSomething() -{ - QStringList list; - list << "AlPha" << "beTA" << "gamma" << "DELTA"; - qStableSort(list.begin(), list.end(), caseInsensitiveLessThan); - // list: [ "AlPha", "beTA", "DELTA", "gamma" ] -} -//! [16] - - -//! [17] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qStableSort(list.begin(), list.end(), qGreater()); -// list: [ 68, 33, 12, 12, 6 ] -//! [17] - - -//! [18] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; - -QList::iterator i = qLowerBound(list.begin(), list.end(), 5); -list.insert(i, 5); -// list: [ 3, 3, 5, 6, 6, 6, 8 ] - -i = qLowerBound(list.begin(), list.end(), 12); -list.insert(i, 12); -// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ] -//! [18] - - -//! [19] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; -QList::iterator begin6 = - qLowerBound(list.begin(), list.end(), 6); -QList::iterator end6 = - qUpperBound(begin6, list.end(), 6); - -QList::iterator i = begin6; -while (i != end6) { - *i = 7; - ++i; -} -// list: [ 3, 3, 7, 7, 7, 8 ] -//! [19] - - -//! [20] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; - -QList::iterator i = qUpperBound(list.begin(), list.end(), 5); -list.insert(i, 5); -// list: [ 3, 3, 5, 6, 6, 6, 8 ] - -i = qUpperBound(list.begin(), list.end(), 12); -list.insert(i, 12); -// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ] -//! [20] - - -//! [21] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; -QList::iterator begin6 = - qLowerBound(list.begin(), list.end(), 6); -QList::iterator end6 = - qUpperBound(list.begin(), list.end(), 6); - -QList::iterator i = begin6; -while (i != end6) { - *i = 7; - ++i; -} -// list: [ 3, 3, 7, 7, 7, 8 ] -//! [21] - - -//! [22] -QList list; -list << 3 << 3 << 6 << 6 << 6 << 8; - -QList::iterator i = - qBinaryFind(list.begin(), list.end(), 6); -// i == list.begin() + 2 (or 3 or 4) -//! [22] +//! [0] -//! [23] +//! [1] QList list; list.append(new Employee("Blackpool", "Stephen")); list.append(new Employee("Twist", "Oliver")); qDeleteAll(list.begin(), list.end()); list.clear(); -//! [23] - - -//! [24] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qSort(list.begin(), list.end(), qLess()); -// list: [ 6, 12, 12, 33, 68 ] -//! [24] - - -//! [25] -QList list; -list << 33 << 12 << 68 << 6 << 12; -qSort(list.begin(), list.end(), qGreater()); -// list: [ 68, 33, 12, 12, 6 ] -//! [25] +//! [1] diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc index f94a6856da..4249cad72e 100644 --- a/src/corelib/tools/qalgorithms.qdoc +++ b/src/corelib/tools/qalgorithms.qdoc @@ -47,8 +47,7 @@ meet a certain set of requirements. 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 + iterators they accept. The iterator types required are specified for each algorithm. If an iterator of the wrong type is passed (for example, if QList::ConstIterator is passed as an \l {Output Iterators}{output iterator}), you will always get a @@ -63,21 +62,7 @@ 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 - plain arrays as containers and plain pointers as iterators. A - common idiom is to use qBinaryFind() together with two static - arrays: one that contains a list of keys, and another that - contains a list of associated values. For example, the following - code will look up an HTML entity (e.g., \c &) in the \c - name_table array and return the corresponding Unicode value from - the \c value_table if the entity is recognized: - - \snippet code/doc_src_qalgorithms.cpp 2 - - This kind of code is for advanced users only; for most - applications, a QMap- or QHash-based approach would work just as - well: - - \snippet code/doc_src_qalgorithms.cpp 3 + plain arrays as containers and plain pointers as iterators. \section1 Types of Iterators @@ -156,7 +141,7 @@ Exchanges the values of variables \a var1 and \a var2. Example: - \snippet code/doc_src_qalgorithms.cpp 10 + \snippet code/doc_src_qalgorithms.cpp 0 */ /*! @@ -168,7 +153,7 @@ example, \c{QWidget *}). Example: - \snippet code/doc_src_qalgorithms.cpp 23 + \snippet code/doc_src_qalgorithms.cpp 1 Notice that qDeleteAll() doesn't remove the items from the container; it merely calls \c delete on them. In the example -- cgit v1.2.3