From a25d34bb056011cd90a3da1a96d0d461b4a5f856 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 29 Jan 2022 05:25:38 +0200 Subject: [PATCH] get rid of QLinkedList Signed-off-by: Ivailo Monev --- CMakeLists.txt | 3 - package/freebsd/pkg-plist | 5 - package/netbsd/PLIST | 5 - package/openbsd/pkg/PLIST | 5 - scripts/incfsck.py | 3 - scripts/namefsck.py | 4 - src/core/CMakeLists.txt | 3 - src/core/io/qdatastream.cpp | 2 +- src/core/io/qdatastream.h | 28 - src/core/tools/qalgorithms.qdoc | 2 +- src/core/tools/qcontainerfwd.h | 1 - src/core/tools/qiterator.qdoc | 123 --- src/core/tools/qlinkedlist.cpp | 1135 ---------------------- src/core/tools/qlinkedlist.h | 458 --------- src/core/tools/qlist.cpp | 26 +- src/core/tools/qvarlengtharray.qdoc | 9 +- src/core/tools/qvector.cpp | 24 +- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 8 +- src/gui/itemviews/qtableview_p.h | 3 +- src/script/api/qscriptvalueiterator.cpp | 8 +- src/tools/uic/cpp/cppwriteincludes.cpp | 2 - tests/auto/qdatastream/tst_qdatastream.cpp | 19 +- util/qlalr/cppgenerator.cpp | 2 +- util/qlalr/lalr.cpp | 4 +- util/qlalr/lalr.h | 21 +- util/qlalr/main.cpp | 2 +- 26 files changed, 49 insertions(+), 1856 deletions(-) delete mode 100644 src/core/tools/qlinkedlist.cpp delete mode 100644 src/core/tools/qlinkedlist.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 643db2c68..8411d80c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -699,9 +699,6 @@ katie_generate_obsolete(QLatin1Char QtCore qchar.h) katie_generate_obsolete(QLatin1String QtCore qstring.h) katie_generate_obsolete(QLinearGradient QtGui qbrush.h) katie_generate_obsolete(QLineF QtCore qline.h) -katie_generate_obsolete(QLinkedListData QtCore qlinkedlist.h) -katie_generate_obsolete(QLinkedListIterator QtCore qlinkedlist.h) -katie_generate_obsolete(QLinkedListNode QtCore qlinkedlist.h) katie_generate_obsolete(QListData QtCore qlist.h) katie_generate_obsolete(QListIterator QtCore qlist.h) katie_generate_obsolete(QListWidgetItem QtGui qlistwidget.h) diff --git a/package/freebsd/pkg-plist b/package/freebsd/pkg-plist index c2ed18573..d1f13a265 100644 --- a/package/freebsd/pkg-plist +++ b/package/freebsd/pkg-plist @@ -76,10 +76,6 @@ include/katie/QtCore/QLibrary include/katie/QtCore/QLibraryInfo include/katie/QtCore/QLine include/katie/QtCore/QLineF -include/katie/QtCore/QLinkedList -include/katie/QtCore/QLinkedListData -include/katie/QtCore/QLinkedListIterator -include/katie/QtCore/QLinkedListNode include/katie/QtCore/QList include/katie/QtCore/QListData include/katie/QtCore/QListIterator @@ -251,7 +247,6 @@ include/katie/QtCore/qjsondocument.h include/katie/QtCore/qlibrary.h include/katie/QtCore/qlibraryinfo.h include/katie/QtCore/qline.h -include/katie/QtCore/qlinkedlist.h include/katie/QtCore/qlist.h include/katie/QtCore/qlocale.h include/katie/QtCore/qmap.h diff --git a/package/netbsd/PLIST b/package/netbsd/PLIST index 3a4ed3ed7..56fbfc65d 100644 --- a/package/netbsd/PLIST +++ b/package/netbsd/PLIST @@ -79,10 +79,6 @@ include/katie/QtCore/QLibrary include/katie/QtCore/QLibraryInfo include/katie/QtCore/QLine include/katie/QtCore/QLineF -include/katie/QtCore/QLinkedList -include/katie/QtCore/QLinkedListData -include/katie/QtCore/QLinkedListIterator -include/katie/QtCore/QLinkedListNode include/katie/QtCore/QList include/katie/QtCore/QListData include/katie/QtCore/QListIterator @@ -254,7 +250,6 @@ include/katie/QtCore/qjsondocument.h include/katie/QtCore/qlibrary.h include/katie/QtCore/qlibraryinfo.h include/katie/QtCore/qline.h -include/katie/QtCore/qlinkedlist.h include/katie/QtCore/qlist.h include/katie/QtCore/qlocale.h include/katie/QtCore/qmap.h diff --git a/package/openbsd/pkg/PLIST b/package/openbsd/pkg/PLIST index b2e99bb70..dde6e51d3 100644 --- a/package/openbsd/pkg/PLIST +++ b/package/openbsd/pkg/PLIST @@ -79,10 +79,6 @@ include/katie/QtCore/QLibrary include/katie/QtCore/QLibraryInfo include/katie/QtCore/QLine include/katie/QtCore/QLineF -include/katie/QtCore/QLinkedList -include/katie/QtCore/QLinkedListData -include/katie/QtCore/QLinkedListIterator -include/katie/QtCore/QLinkedListNode include/katie/QtCore/QList include/katie/QtCore/QListData include/katie/QtCore/QListIterator @@ -254,7 +250,6 @@ include/katie/QtCore/qjsondocument.h include/katie/QtCore/qlibrary.h include/katie/QtCore/qlibraryinfo.h include/katie/QtCore/qline.h -include/katie/QtCore/qlinkedlist.h include/katie/QtCore/qlist.h include/katie/QtCore/qlocale.h include/katie/QtCore/qmap.h diff --git a/scripts/incfsck.py b/scripts/incfsck.py index dc56dda56..08b3f6f30 100755 --- a/scripts/incfsck.py +++ b/scripts/incfsck.py @@ -37,9 +37,6 @@ incmap = { 'QLatin1Char': 'qchar.h', 'QLatin1String': 'qstring.h', 'QLineF': 'qline.h', - 'QLinkedListData': 'qlinkedlist.h', - 'QLinkedListIterator': 'qlinkedlist.h', - 'QLinkedListNode': 'qlinkedlist.h', 'QListData': 'qlist.h', 'QListIterator': 'qlist.h', 'QMapData': 'qmap.h', diff --git a/scripts/namefsck.py b/scripts/namefsck.py index 924f31ccc..76a39f576 100755 --- a/scripts/namefsck.py +++ b/scripts/namefsck.py @@ -343,10 +343,6 @@ classlist = [ "QLinearGradient", "QLineEdit", "QLineF", - "QLinkedList", - "QLinkedListData", - "QLinkedListIterator", - "QLinkedListNode", "QList", "QListData", "QListIterator", diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 5ea6d415d..7bf421ded 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -62,7 +62,6 @@ set(CORE_PUBLIC_HEADERS QFutureWatcher QVector QLibraryInfo - QLinkedList QSemaphore QFutureSynchronizer QStack @@ -246,7 +245,6 @@ set(CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/tools/qhash.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qjsondocument.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qline.h - ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlinkedlist.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlist.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlocale.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlocale_p.h @@ -376,7 +374,6 @@ set(CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tools/qhash.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tools/qjsondocument.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tools/qline.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlinkedlist.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlist.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlocale.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tools/qlocale_tools.cpp diff --git a/src/core/io/qdatastream.cpp b/src/core/io/qdatastream.cpp index 50a446549..58f934403 100644 --- a/src/core/io/qdatastream.cpp +++ b/src/core/io/qdatastream.cpp @@ -141,7 +141,7 @@ QT_BEGIN_NAMESPACE \section1 Reading and writing Qt collection classes The Qt container classes can also be serialized to a QDataStream. - These include QList, QLinkedList, QVector, QSet, QHash, and QMap. + These include QList, QVector, QSet, QHash, and QMap. The stream operators are declared as non-members of the classes. \target Serializing Qt Classes diff --git a/src/core/io/qdatastream.h b/src/core/io/qdatastream.h index 75ab5c712..87582a770 100644 --- a/src/core/io/qdatastream.h +++ b/src/core/io/qdatastream.h @@ -31,7 +31,6 @@ QT_BEGIN_NAMESPACE class QByteArray; template class QList; -template class QLinkedList; template class QVector; template class QSet; template class QHash; @@ -213,33 +212,6 @@ QDataStream& operator<<(QDataStream& s, const QList& l) return s; } -template -QDataStream& operator>>(QDataStream& s, QLinkedList& l) -{ - l.clear(); - quint32 c; - s >> c; - for(quint32 i = 0; i < c; ++i) - { - T t; - s >> t; - l.append(t); - if (s.atEnd()) - break; - } - return s; -} - -template -QDataStream& operator<<(QDataStream& s, const QLinkedList& l) -{ - s << quint32(l.size()); - typename QLinkedList::const_iterator it = l.constBegin(); - for(; it != l.constEnd(); ++it) - s << *it; - return s; -} - template QDataStream& operator>>(QDataStream& s, QVector& v) { diff --git a/src/core/tools/qalgorithms.qdoc b/src/core/tools/qalgorithms.qdoc index 7437c927a..e82f5f57d 100644 --- a/src/core/tools/qalgorithms.qdoc +++ b/src/core/tools/qalgorithms.qdoc @@ -28,7 +28,7 @@ that work on containers and perform well-know algorithms. 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. + QVector, QMap, and QHash classes. These functions have taken their inspiration from similar functions available in the STL \c header. Most of them diff --git a/src/core/tools/qcontainerfwd.h b/src/core/tools/qcontainerfwd.h index f3aba6467..3984b43c9 100644 --- a/src/core/tools/qcontainerfwd.h +++ b/src/core/tools/qcontainerfwd.h @@ -29,7 +29,6 @@ QT_BEGIN_NAMESPACE template class QCache; template class QHash; -template class QLinkedList; template class QList; template class QMap; template class QMultiHash; diff --git a/src/core/tools/qiterator.qdoc b/src/core/tools/qiterator.qdoc index b320b565e..36eff19e0 100644 --- a/src/core/tools/qiterator.qdoc +++ b/src/core/tools/qiterator.qdoc @@ -71,54 +71,6 @@ */ /*! - \class QLinkedListIterator - \inmodule QtCore - - \brief The QLinkedListIterator class provides a Java-style const iterator for QLinkedList. - - QLinkedList has both \l{Java-style iterators} and - \l{STL-style iterators}. The Java-style iterators are more - high-level and easier to use than the STL-style iterators; on the - other hand, they are slightly less efficient. - - QLinkedListIterator\ allows you to iterate over a - QLinkedList\. If you want to modify the list as you iterate - over it, use QMutableLinkedListIterator\ instead. - - The QLinkedListIterator constructor takes a QLinkedList as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.cpp 2 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, and returns the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.cpp 3 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same list. If the list is - modified while a QLinkedListIterator is active, the - QLinkedListIterator will continue iterating over the original - list, ignoring the modified copy. - - \sa QMutableLinkedListIterator, QLinkedList::const_iterator -*/ - -/*! \class QVectorIterator \inmodule QtCore \brief The QVectorIterator class provides a Java-style const iterator for QVector and QStack. @@ -284,67 +236,6 @@ */ /*! - \class QMutableLinkedListIterator - \inmodule QtCore - - \brief The QMutableLinkedListIterator class provides a Java-style non-const iterator for QLinkedList. - - QLinkedList has both \l{Java-style iterators} and - \l{STL-style iterators}. The Java-style iterators are more - high-level and easier to use than the STL-style iterators; on the - other hand, they are slightly less efficient. - - QMutableLinkedListIterator\ allows you to iterate over a - QLinkedList\ and modify the list. If you don't want to modify - the list (or have a const QLinkedList), use the slightly faster - QLinkedListIterator\ instead. - - The QMutableLinkedListIterator constructor takes a QLinkedList as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet doc/src/snippets/code/doc_src_qiterator.cpp 11 - - The next() function returns the next item in the list and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \img javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet doc/src/snippets/code/doc_src_qiterator.cpp 12 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - If you want to remove items as you iterate over the list, use - remove(). If you want to modify the value of an item, use - setValue(). If you want to insert a new item in the list, use - insert(). - - Example: - \snippet doc/src/snippets/code/doc_src_qiterator.cpp 13 - - The example traverses a list, replacing negative numbers with - their absolute values, and eliminating zeroes. - - Only one mutable iterator can be active on a given list at any - time. Furthermore, no changes should be done directly to the list - while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QLinkedListIterator, QLinkedList::iterator -*/ - -/*! \class QMutableVectorIterator \inmodule QtCore @@ -463,9 +354,7 @@ /*! \fn QListIterator::QListIterator(const QList &list) - \fn QLinkedListIterator::QLinkedListIterator(const QLinkedList &list) \fn QMutableListIterator::QMutableListIterator(QList &list) - \fn QMutableLinkedListIterator::QMutableLinkedListIterator(QLinkedList &list) Constructs an iterator for traversing \a list. The iterator is set to be at the front of the list (before the first item). @@ -505,9 +394,7 @@ */ /*! \fn QMutableListIterator &QMutableListIterator::operator=(QList &list) - \fn QMutableLinkedListIterator &QMutableLinkedListIterator::operator=(QLinkedList &list) \fn QListIterator &QListIterator::operator=(const QList &list) - \fn QLinkedListIterator &QLinkedListIterator::operator=(const QLinkedList &list) Makes the iterator operate on \a list. The iterator is set to be at the front of the list (before the first item). @@ -534,7 +421,6 @@ */ /*! \fn void QListIterator::toFront() - \fn void QLinkedListIterator::toFront() \fn void QVectorIterator::toFront() \fn void QSetIterator::toFront() \fn void QMutableListIterator::toFront() @@ -549,7 +435,6 @@ */ /*! \fn void QListIterator::toBack() - \fn void QLinkedListIterator::toBack() \fn void QVectorIterator::toBack() \fn void QSetIterator::toBack() \fn void QMutableListIterator::toBack() @@ -564,7 +449,6 @@ */ /*! \fn bool QListIterator::hasNext() const - \fn bool QLinkedListIterator::hasNext() const \fn bool QVectorIterator::hasNext() const \fn bool QSetIterator::hasNext() const \fn bool QMutableListIterator::hasNext() const @@ -580,7 +464,6 @@ */ /*! \fn const T &QListIterator::next() - \fn const T &QLinkedListIterator::next() \fn const T &QVectorIterator::next() \fn const T &QSetIterator::next() \fn const T &QMutableSetIterator::next() @@ -607,7 +490,6 @@ */ /*! \fn const T &QListIterator::peekNext() const - \fn const T &QLinkedListIterator::peekNext() const \fn const T &QVectorIterator::peekNext() const \fn const T &QSetIterator::peekNext() const \fn const T &QMutableSetIterator::peekNext() const @@ -633,7 +515,6 @@ */ /*! \fn bool QListIterator::hasPrevious() const - \fn bool QLinkedListIterator::hasPrevious() const \fn bool QVectorIterator::hasPrevious() const \fn bool QSetIterator::hasPrevious() const \fn bool QMutableListIterator::hasPrevious() const @@ -649,7 +530,6 @@ */ /*! \fn const T &QListIterator::previous() - \fn const T &QLinkedListIterator::previous() \fn const T &QVectorIterator::previous() \fn const T &QSetIterator::previous() \fn const T &QMutableSetIterator::previous() @@ -677,7 +557,6 @@ */ /*! \fn const T &QListIterator::peekPrevious() const - \fn const T &QLinkedListIterator::peekPrevious() const \fn const T &QVectorIterator::peekPrevious() const \fn const T &QSetIterator::peekPrevious() const \fn const T &QMutableSetIterator::peekPrevious() const @@ -703,7 +582,6 @@ */ /*! \fn bool QListIterator::findNext(const T &value) - \fn bool QLinkedListIterator::findNext(const T &value) \fn bool QVectorIterator::findNext(const T &value) \fn bool QSetIterator::findNext(const T &value) \fn bool QMutableListIterator::findNext(const T &value) @@ -722,7 +600,6 @@ */ /*! \fn bool QListIterator::findPrevious(const T &value) - \fn bool QLinkedListIterator::findPrevious(const T &value) \fn bool QVectorIterator::findPrevious(const T &value) \fn bool QSetIterator::findPrevious(const T &value) \fn bool QMutableListIterator::findPrevious(const T &value) diff --git a/src/core/tools/qlinkedlist.cpp b/src/core/tools/qlinkedlist.cpp deleted file mode 100644 index 6cdccb4c0..000000000 --- a/src/core/tools/qlinkedlist.cpp +++ /dev/null @@ -1,1135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtCore module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qlinkedlist.h" - -QT_BEGIN_NAMESPACE - -QLinkedListData QLinkedListData::shared_null = { - &QLinkedListData::shared_null, &QLinkedListData::shared_null, - QAtomicInt(1), 0 -}; - -/*! \class QLinkedList - \brief The QLinkedList class is a template class that provides linked lists. - - \ingroup tools - \ingroup shared - - \reentrant - - QLinkedList\ is one of Qt's generic \l{container classes}. It - stores a list of values and provides iterator-based access as - well as \l{constant time} insertions and removals. - - QList\, QLinkedList\, and QVector\ provide similar - functionality. Here's an overview: - - \list - \i For most purposes, QList is the right class to use. Its - index-based API is more convenient than QLinkedList's - iterator-based API, and it is usually faster than - QVector because of the way it stores its items in - memory (see \l{Algorithmic Complexity} for details). - It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant - time} insertions in the middle of the list and iterators to - items rather than indexes, use QLinkedList. - \i If you want the items to occupy adjacent memory positions, - use QVector. - \endlist - - Here's an example of a QLinkedList that stores integers and a - QLinkedList that stores QTime values: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 0 - - QLinkedList stores a list of items. The default constructor - creates an empty list. To insert items into the list, you can use - operator<<(): - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 1 - - If you want to get the first or last item in a linked list, use - first() or last(). If you want to remove an item from either end - of the list, use removeFirst() or removeLast(). If you want to - remove all occurrences of a given value in the list, use - removeAll(). - - A common requirement is to remove the first or last item in the - list and do something with it. For this, QLinkedList provides - takeFirst() and takeLast(). Here's a loop that removes the items - from a list one at a time and calls \c delete on them: - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 2 - - QLinkedList's value type must be an \l {assignable data type}. This - covers most data types that are commonly used, but the compiler - won't let you, for example, store a QWidget as a value; instead, - store a QWidget *. A few functions have additional requirements; - for example, contains() and removeAll() expect the value type to - support \c operator==(). These requirements are documented on a - per-function basis. - - If you want to insert, modify, or remove items in the middle of - the list, you must use an iterator. QLinkedList provides both - \l{Java-style iterators} (QLinkedListIterator and - QMutableLinkedListIterator) and \l{STL-style iterators} - (QLinkedList::const_iterator and QLinkedList::iterator). See the - documentation for these classes for details. - - \sa QLinkedListIterator, QMutableLinkedListIterator, QList, QVector -*/ - -/*! \fn QLinkedList::QLinkedList() - - Constructs an empty list. -*/ - -/*! \fn QLinkedList::QLinkedList(const QLinkedList &other) - - Constructs a copy of \a other. - - This operation occurs in \l{constant time}, because QLinkedList - is \l{implicitly shared}. This makes returning a QLinkedList from - a function very fast. If a shared instance is modified, it will - be copied (copy-on-write), and this takes \l{linear time}. - - \sa operator=() -*/ - -/*! \fn QLinkedList::~QLinkedList() - - Destroys the list. References to the values in the list, and all - iterators over this list, become invalid. -*/ - -/*! \fn QLinkedList &QLinkedList::operator=(const QLinkedList &other) - - Assigns \a other to this list and returns a reference to this - list. -*/ - -/*! \fn void QLinkedList::swap(QLinkedList &other) - \since 4.8 - - Swaps list \a other with this list. This operation is very - fast and never fails. -*/ - -/*! \fn bool QLinkedList::operator==(const QLinkedList &other) const - - Returns true if \a other is equal to this list; otherwise returns - false. - - Two lists are considered equal if they contain the same values in - the same order. - - This function requires the value type to implement \c - operator==(). - - \sa operator!=() -*/ - -/*! \fn bool QLinkedList::operator!=(const QLinkedList &other) const - - Returns true if \a other is not equal to this list; otherwise - returns false. - - Two lists are considered equal if they contain the same values in - the same order. - - This function requires the value type to implement \c - operator==(). - - \sa operator==() -*/ - -/*! \fn int QLinkedList::size() const - - Returns the number of items in the list. - - \sa isEmpty(), count() -*/ - -/*! \fn void QLinkedList::detach() - - \internal -*/ - -/*! \fn bool QLinkedList::isEmpty() const - - Returns true if the list contains no items; otherwise returns - false. - - \sa size() -*/ - -/*! \fn void QLinkedList::clear() - - Removes all the items in the list. - - \sa removeAll() -*/ - -/*! \fn void QLinkedList::append(const T &value) - - Inserts \a value at the end of the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 3 - - This is the same as list.insert(end(), \a value). - - \sa operator<<(), prepend(), insert() -*/ - -/*! \fn void QLinkedList::prepend(const T &value) - - Inserts \a value at the beginning of the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 4 - - This is the same as list.insert(begin(), \a value). - - \sa append(), insert() -*/ - -/*! \fn int QLinkedList::removeAll(const T &value) - - Removes all occurrences of \a value in the list. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 5 - - This function requires the value type to have an implementation of - \c operator==(). - - \sa insert() -*/ - -/*! - \fn bool QLinkedList::removeOne(const T &value) - \since 4.4 - - Removes the first occurrences of \a value in the list. Returns true on - success; otherwise returns false. - - Example: - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 6 - - This function requires the value type to have an implementation of - \c operator==(). - - \sa insert() -*/ - -/*! \fn bool QLinkedList::contains(const T &value) const - - Returns true if the list contains an occurrence of \a value; - otherwise returns false. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa QLinkedListIterator::findNext(), QLinkedListIterator::findPrevious() -*/ - -/*! \fn int QLinkedList::count(const T &value) const - - Returns the number of occurrences of \a value in the list. - - This function requires the value type to have an implementation of - \c operator==(). - - \sa contains() -*/ - -/*! \fn bool QLinkedList::startsWith(const T &value) const - \since 4.5 - - Returns true if the list is not empty and its first - item is equal to \a value; otherwise returns false. - - \sa isEmpty(), first() -*/ - -/*! \fn bool QLinkedList::endsWith(const T &value) const - \since 4.5 - - Returns true if the list is not empty and its last - item is equal to \a value; otherwise returns false. - - \sa isEmpty(), last() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::begin() - - Returns an \l{STL-style iterator} pointing to the first item in - the list. - - \sa constBegin(), end() -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::begin() const - - \overload -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::constBegin() const - - Returns a const \l{STL-style iterator} pointing to the first item - in the list. - - \sa begin(), constEnd() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::end() - - Returns an \l{STL-style iterator} pointing to the imaginary item - after the last item in the list. - - \sa begin(), constEnd() -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::end() const - - \overload -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::constEnd() const - - Returns a const \l{STL-style iterator} pointing to the imaginary - item after the last item in the list. - - \sa constBegin(), end() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::insert(iterator before, const T &value) - - Inserts \a value in front of the item pointed to by the iterator - \a before. Returns an iterator pointing at the inserted item. - - \sa erase() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::erase(iterator pos) - - Removes the item pointed to by the iterator \a pos from the list, - and returns an iterator to the next item in the list (which may be - end()). - - \sa insert() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::erase(iterator begin, iterator end) - - \overload - - Removes all the items from \a begin up to (but not including) \a - end. -*/ - -/*! \typedef QLinkedList::Iterator - - Qt-style synonym for QLinkedList::iterator. -*/ - -/*! \typedef QLinkedList::ConstIterator - - Qt-style synonym for QLinkedList::const_iterator. -*/ - -/*! - \typedef QLinkedList::size_type - - Typedef for int. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::value_type - - Typedef for T. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::pointer - - Typedef for T *. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::const_pointer - - Typedef for const T *. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::reference - - Typedef for T &. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::const_reference - - Typedef for const T &. Provided for STL compatibility. -*/ - -/*! - \typedef QLinkedList::difference_type - - Typedef for ptrdiff_t. Provided for STL compatibility. -*/ - -/*! \fn int QLinkedList::count() const - - Same as size(). -*/ - -/*! \fn T& QLinkedList::first() - - Returns a reference to the first item in the list. This function - assumes that the list isn't empty. - - \sa last(), isEmpty() -*/ - -/*! \fn const T& QLinkedList::first() const - - \overload -*/ - -/*! \fn T& QLinkedList::last() - - Returns a reference to the last item in the list. This function - assumes that the list isn't empty. - - \sa first(), isEmpty() -*/ - -/*! \fn const T& QLinkedList::last() const - - \overload -*/ - -/*! \fn void QLinkedList::removeFirst() - - Removes the first item in the list. - - This is the same as erase(begin()). - - \sa removeLast(), erase() -*/ - -/*! \fn void QLinkedList::removeLast() - - Removes the last item in the list. - - \sa removeFirst(), erase() -*/ - -/*! \fn T QLinkedList::takeFirst() - - Removes the first item in the list and returns it. - - If you don't use the return value, removeFirst() is more - efficient. - - \sa takeLast(), removeFirst() -*/ - -/*! \fn T QLinkedList::takeLast() - - Removes the last item in the list and returns it. - - If you don't use the return value, removeLast() is more - efficient. - - \sa takeFirst(), removeLast() -*/ - -/*! \fn void QLinkedList::push_back(const T &value) - - This function is provided for STL compatibility. It is equivalent - to append(\a value). -*/ - -/*! \fn void QLinkedList::push_front(const T &value) - - This function is provided for STL compatibility. It is equivalent - to prepend(\a value). -*/ - -/*! \fn T& QLinkedList::front() - - This function is provided for STL compatibility. It is equivalent - to first(). -*/ - -/*! \fn const T& QLinkedList::front() const - - \overload -*/ - -/*! \fn T& QLinkedList::back() - - This function is provided for STL compatibility. It is equivalent - to last(). -*/ - -/*! \fn const T& QLinkedList::back() const - - \overload -*/ - -/*! \fn void QLinkedList::pop_front() - - This function is provided for STL compatibility. It is equivalent - to removeFirst(). -*/ - -/*! \fn void QLinkedList::pop_back() - - This function is provided for STL compatibility. It is equivalent - to removeLast(). -*/ - -/*! \fn bool QLinkedList::empty() const - - This function is provided for STL compatibility. It is equivalent - to isEmpty() and returns true if the list is empty. -*/ - -/*! \fn QLinkedList &QLinkedList::operator+=(const QLinkedList &other) - - Appends the items of the \a other list to this list and returns a - reference to this list. - - \sa operator+(), append() -*/ - -/*! \fn void QLinkedList::operator+=(const T &value) - - \overload - - Appends \a value to the list. -*/ - -/*! \fn QLinkedList QLinkedList::operator+(const QLinkedList &other) const - - Returns a list that contains all the items in this list followed - by all the items in the \a other list. - - \sa operator+=() -*/ - -/*! \fn QLinkedList &QLinkedList::operator<<(const QLinkedList &other) - - Appends the items of the \a other list to this list and returns a - reference to this list. - - \sa operator+=(), append() -*/ - -/*! \fn QLinkedList &QLinkedList::operator<<(const T &value) - - \overload - - Appends \a value to the list. -*/ - -/*! \class QLinkedList::iterator - \brief The QLinkedList::iterator class provides an STL-style non-const iterator for QLinkedList. - - QLinkedList features both \l{STL-style iterators} and - \l{Java-style iterators}. The STL-style iterators are more - low-level and more cumbersome to use; on the other hand, they are - slightly faster and, for developers who already know STL, have - the advantage of familiarity. - - QLinkedList\::iterator allows you to iterate over a - QLinkedList\ and to modify the list item associated with the - iterator. If you want to iterate over a const QLinkedList, use - QLinkedList::const_iterator instead. It is generally good - practice to use QLinkedList::const_iterator on a non-const - QLinkedList as well, unless you need to change the QLinkedList - through the iterator. Const iterators are slightly faster, and - can improve code readability. - - The default QLinkedList::iterator constructor creates an - uninitialized iterator. You must initialize it using a - function like QLinkedList::begin(), QLinkedList::end(), or - QLinkedList::insert() before you can start iterating. Here's a - typical loop that prints all the items stored in a list: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 7 - - STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the list - using the qFind() algorithm: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 8 - - Let's see a few examples of things we can do with a - QLinkedList::iterator that we cannot do with a QLinkedList::const_iterator. - Here's an example that increments every value stored in a - QLinkedList\ by 2: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 9 - - Here's an example that removes all the items that start with an - underscore character in a QLinkedList\: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 10 - - The call to QLinkedList::erase() removes the item pointed to by - the iterator from the list, and returns an iterator to the next - item. Here's another way of removing an item while iterating: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 11 - - It might be tempting to write code like this: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 12 - - However, this will potentially crash in \c{++i}, because \c i is - a dangling iterator after the call to erase(). - - Multiple iterators can be used on the same list. If you add items - to the list, existing iterators will remain valid. If you remove - items from the list, iterators that point to the removed items - will become dangling iterators. However, because of how \l{implicit - sharing} works, you must not take a copy of a container while - iterators are active on that container. - - \sa QLinkedList::const_iterator, QMutableLinkedListIterator -*/ - -/*! \fn QLinkedList::iterator::iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called - on an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QLinkedList::begin() QLinkedList::end() -*/ - -/*! \fn QLinkedList::iterator::iterator(Node *node) - - \internal -*/ - -/*! \typedef QLinkedList::iterator::iterator_category - - \internal -*/ - -/*! \typedef QLinkedList::iterator::difference_type - - \internal -*/ - -/*! \typedef QLinkedList::iterator::value_type - - \internal -*/ - -/*! \typedef QLinkedList::iterator::pointer - - \internal -*/ - -/*! \typedef QLinkedList::iterator::reference - - \internal -*/ - -/*! \fn QLinkedList::iterator::iterator(const iterator &other) - - Constructs a copy of \a other. -*/ - -/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator=(const iterator &other) - - Assigns \a other to this iterator. -*/ - -/*! \fn T &QLinkedList::iterator::operator*() const - - Returns a modifiable reference to the current item. - - You can change the value of an item by using operator*() on the - left side of an assignment, for example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 13 - - \sa operator->() -*/ - -/*! \fn T *QLinkedList::iterator::operator->() const - - Returns a pointer to the current item. - - \sa operator*() -*/ - -/*! - \fn bool QLinkedList::iterator::operator==(const iterator &other) const - \fn bool QLinkedList::iterator::operator==(const const_iterator &other) const - - Returns true if \a other points to the same item as this - iterator; otherwise returns false. - - \sa operator!=() -*/ - -/*! - \fn bool QLinkedList::iterator::operator!=(const iterator &other) const - \fn bool QLinkedList::iterator::operator!=(const const_iterator &other) const - - Returns true if \a other points to a different item than this - iterator; otherwise returns false. - - \sa operator==() -*/ - -/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator++() - - The prefix ++ operator (\c{++it}) advances the iterator to the - next item in the list and returns an iterator to the new current - item. - - Calling this function on QLinkedList::end() leads to undefined - results. - - \sa operator--() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::iterator::operator++(int) - - \overload - - The postfix ++ operator (\c{it++}) advances the iterator to the - next item in the list and returns an iterator to the previously - current item. -*/ - -/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator--() - - The prefix -- operator (\c{--it}) makes the preceding item - current and returns an iterator to the new current item. - - Calling this function on QLinkedList::begin() leads to undefined - results. - - \sa operator++() -*/ - -/*! \fn QLinkedList::iterator QLinkedList::iterator::operator--(int) - - \overload - - The postfix -- operator (\c{it--}) makes the preceding item - current and returns an iterator to the previously current item. -*/ - -/*! \fn QLinkedList::iterator QLinkedList::iterator::operator+(int j) const - - Returns an iterator to the item at \a j positions forward from - this iterator. (If \a j is negative, the iterator goes backward.) - - This operation can be slow for large \a j values. - - \sa operator-() - -*/ - -/*! \fn QLinkedList::iterator QLinkedList::iterator::operator-(int j) const - - Returns an iterator to the item at \a j positions backward from - this iterator. (If \a j is negative, the iterator goes forward.) - - This operation can be slow for large \a j values. - - \sa operator+() -*/ - -/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator+=(int j) - - Advances the iterator by \a j items. (If \a j is negative, the - iterator goes backward.) - - \sa operator-=(), operator+() -*/ - -/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator-=(int j) - - Makes the iterator go back by \a j items. (If \a j is negative, - the iterator goes forward.) - - \sa operator+=(), operator-() -*/ - -/*! \class QLinkedList::const_iterator - \brief The QLinkedList::const_iterator class provides an STL-style const iterator for QLinkedList. - - QLinkedList features both \l{STL-style iterators} and - \l{Java-style iterators}. The STL-style iterators are more - low-level and more cumbersome to use; on the other hand, they are - slightly faster and, for developers who already know STL, have - the advantage of familiarity. - - QLinkedList\::const_iterator allows you to iterate over a - QLinkedList\. If you want modify the QLinkedList as you iterate - over it, you must use QLinkedList::iterator instead. It is - generally good practice to use QLinkedList::const_iterator on a - non-const QLinkedList as well, unless you need to change the - QLinkedList through the iterator. Const iterators are slightly - faster, and can improve code readability. - - The default QLinkedList::const_iterator constructor creates an - uninitialized iterator. You must initialize it using a function - like QLinkedList::constBegin(), QLinkedList::constEnd(), or - QLinkedList::insert() before you can start iterating. Here's a - typical loop that prints all the items stored in a list: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 14 - - STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the list - using the qFind() algorithm: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 15 - - Multiple iterators can be used on the same list. If you add items - to the list, existing iterators will remain valid. If you remove - items from the list, iterators that point to the removed items - will become dangling iterators. - - \sa QLinkedList::iterator, QLinkedListIterator -*/ - -/*! \fn QLinkedList::const_iterator::const_iterator() - - Constructs an uninitialized iterator. - - Functions like operator*() and operator++() should not be called - on an uninitialized iterator. Use operator=() to assign a value - to it before using it. - - \sa QLinkedList::constBegin() QLinkedList::constEnd() -*/ - -/*! \fn QLinkedList::const_iterator::const_iterator(Node *node) - - \internal -*/ - -/*! \typedef QLinkedList::const_iterator::iterator_category - - \internal -*/ - -/*! \typedef QLinkedList::const_iterator::difference_type - - \internal -*/ - -/*! \typedef QLinkedList::const_iterator::value_type - - \internal -*/ - -/*! \typedef QLinkedList::const_iterator::pointer - - \internal -*/ - -/*! \typedef QLinkedList::const_iterator::reference - - \internal -*/ - -/*! \fn QLinkedList::const_iterator::const_iterator(const const_iterator &other) - - Constructs a copy of \a other. -*/ - -/*! \fn QLinkedList::const_iterator::const_iterator(iterator other) - - Constructs a copy of \a other. -*/ - -/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator=( \ - const const_iterator &other) - - Assigns \a other to this iterator. -*/ - -/*! \fn const T &QLinkedList::const_iterator::operator*() const - - Returns a reference to the current item. - - \sa operator->() -*/ - -/*! \fn const T *QLinkedList::const_iterator::operator->() const - - Returns a pointer to the current item. - - \sa operator*() -*/ - -/*! \fn bool QLinkedList::const_iterator::operator==(const const_iterator &other) const - - Returns true if \a other points to the same item as this - iterator; otherwise returns false. - - \sa operator!=() -*/ - -/*! \fn bool QLinkedList::const_iterator::operator!=(const const_iterator &other) const - - Returns true if \a other points to a different item than this - iterator; otherwise returns false. - - \sa operator==() -*/ - -/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator++() - - The prefix ++ operator (\c{++it}) advances the iterator to the - next item in the list and returns an iterator to the new current - item. - - Calling this function on QLinkedList::constEnd() leads to - undefined results. - - \sa operator--() -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator++(int) - - \overload - - The postfix ++ operator (\c{it++}) advances the iterator to the - next item in the list and returns an iterator to the previously - current item. -*/ - -/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator--() - - The prefix -- operator (\c{--it}) makes the preceding item - current and returns an iterator to the new current item. - - Calling this function on QLinkedList::begin() leads to undefined - results. - - \sa operator++() -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator--(int) - - \overload - - The postfix -- operator (\c{it--}) makes the preceding item - current and returns an iterator to the previously current item. -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator+(int j) const - - Returns an iterator to the item at \a j positions forward from - this iterator. (If \a j is negative, the iterator goes backward.) - - This operation can be slow for large \a j values. - - \sa operator-() -*/ - -/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator-(int j) const - - This function returns an iterator to the item at \a j positions backward from - this iterator. (If \a j is negative, the iterator goes forward.) - - This operation can be slow for large \a j values. - - \sa operator+() -*/ - -/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator+=(int j) - - Advances the iterator by \a j items. (If \a j is negative, the - iterator goes backward.) - - This operation can be slow for large \a j values. - - \sa operator-=(), operator+() -*/ - -/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator-=(int j) - - Makes the iterator go back by \a j items. (If \a j is negative, - the iterator goes forward.) - - This operation can be slow for large \a j values. - - \sa operator+=(), operator-() -*/ - -/*! \fn QDataStream &operator<<(QDataStream &out, const QLinkedList &list) - \relates QLinkedList - - Writes the linked list \a list to stream \a out. - - This function requires the value type to implement \c - operator<<(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -/*! \fn QDataStream &operator>>(QDataStream &in, QLinkedList &list) - \relates QLinkedList - - Reads a linked list from stream \a in into \a list. - - This function requires the value type to implement \c operator>>(). - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -/*! - \fn iterator QLinkedList::remove(iterator pos) - - Use erase() instead. -*/ - -/*! - \fn int QLinkedList::findIndex(const T& t) const - - If you need indexes then QList or QVector are better choices than - QLinkedList. - - \oldcode - int index = list->findIndex(value); - \newcode - int index = 0; - bool found = false; - for (const_iterator i = list->begin(); i != list->end(); ++i; ++index) - if (*i == value) { - found = true; - break; - } - if (!found) - index = -1; - \endcode -*/ - -/*! - \fn iterator QLinkedList::find(iterator from, const T& t) - - If you need random access to a data structure then QList, QVector, - QMap, or QHash, are all better choices than QLinkedList. - - \oldcode - QLinkedList::iterator i = list->find(from, value); - \newcode - QLinkedList::iterator i = from; - while (i != list->end() && *i != value) - ++i; - \endcode -*/ - -/*! - \fn iterator QLinkedList::find(const T& t) - - If you need random access to a data structure then QList, QVector, - QMap, or QHash, are all better choices than QLinkedList. - - \oldcode - QLinkedList::iterator i = list->find(value); - \newcode - QLinkedList::iterator i = list->begin(); - while (i != list->end() && *i != value) - ++i; - \endcode -*/ - -/*! - \fn const_iterator QLinkedList::find(const_iterator from, const T& t) const - - If you need random access to a data structure then QList, QVector, - QMap, or QHash, are all better choices than QLinkedList. - - \oldcode - QLinkedList::const_iterator i = list->find(from, value); - \newcode - QLinkedList::const_iterator i = from; - while (i != list->end() && *i != value) - ++i; - \endcode -*/ - -/*! - \fn const_iterator QLinkedList::find(const T& t) const - - If you need random access to a data structure then QList, QVector, - QMap, or QHash, are all better choices than QLinkedList. - - \oldcode - QLinkedList::const_iterator i = list->find(value); - \newcode - QLinkedList::const_iterator i = list->begin(); - while (i != list->end() && *i != value) - ++i; - \endcode -*/ - -/*! - \since 4.1 - \fn QLinkedList QLinkedList::fromStdList(const std::list &list) - - Returns a QLinkedList object with the data contained in \a list. - The order of the elements in the QLinkedList is the same as in \a - list. - - Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 16 - - \sa toStdList() -*/ - -/*! - \since 4.1 - \fn std::list QLinkedList::toStdList() const - - Returns a std::list object with the data contained in this - QLinkedList. Example: - - \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 17 - - \sa fromStdList() -*/ - -QT_END_NAMESPACE diff --git a/src/core/tools/qlinkedlist.h b/src/core/tools/qlinkedlist.h deleted file mode 100644 index 68d907bc2..000000000 --- a/src/core/tools/qlinkedlist.h +++ /dev/null @@ -1,458 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtCore module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLINKEDLIST_H -#define QLINKEDLIST_H - -#include -#include - -#include -#include - - -QT_BEGIN_NAMESPACE - - -struct Q_CORE_EXPORT QLinkedListData -{ - QLinkedListData *n, *p; - QAtomicInt ref; - int size; - - static QLinkedListData shared_null; -}; - -template -struct QLinkedListNode -{ - inline QLinkedListNode(const T &arg): t(arg) { } - QLinkedListNode *n, *p; - T t; -}; - -template -class Q_CORE_EXPORT QLinkedList -{ - typedef QLinkedListNode Node; - union { QLinkedListData *d; QLinkedListNode *e; }; - -public: - inline QLinkedList() : d(&QLinkedListData::shared_null) { d->ref.ref(); } - inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); } - ~QLinkedList(); - QLinkedList &operator=(const QLinkedList &); - inline QLinkedList &operator=(QLinkedList &&other) - { qSwap(d, other.d); return *this; } - inline void swap(QLinkedList &other) { qSwap(d, other.d); } - bool operator==(const QLinkedList &l) const; - inline bool operator!=(const QLinkedList &l) const { return !(*this == l); } - - inline int size() const { return d->size; } - inline bool isEmpty() const { return d->size == 0; } - - void clear(); - - void append(const T &); - void prepend(const T &); - T takeFirst(); - T takeLast(); - int removeAll(const T &t); - bool removeOne(const T &t); - bool contains(const T &t) const; - int count(const T &t) const; - - class const_iterator; - - class iterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef qptrdiff difference_type; - typedef T value_type; - typedef T *pointer; - typedef T &reference; - Node *i; - inline iterator() : i(nullptr) {} - inline iterator(Node *n) : i(n) {} - inline iterator(const iterator &o) : i(o.i) {} - inline iterator &operator=(const iterator &o) { i = o.i; return *this; } - inline T &operator*() const { return i->t; } - inline T *operator->() const { return &i->t; } - inline bool operator==(const iterator &o) const { return i == o.i; } - inline bool operator!=(const iterator &o) const { return i != o.i; } - inline bool operator==(const const_iterator &o) const - { return i == o.i; } - inline bool operator!=(const const_iterator &o) const - { return i != o.i; } - inline iterator &operator++() { i = i->n; return *this; } - inline iterator operator++(int) { Node *n = i; i = i->n; return n; } - inline iterator &operator--() { i = i->p; return *this; } - inline iterator operator--(int) { Node *n = i; i = i->p; return n; } - inline iterator operator+(int j) const - { Node *n = i; if (j > 0) while (j--) n = n->n; else while (j++) n = n->p; return n; } - inline iterator operator-(int j) const { return operator+(-j); } - inline iterator &operator+=(int j) { return *this = *this + j; } - inline iterator &operator-=(int j) { return *this = *this - j; } - }; - friend class iterator; - - class const_iterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef qptrdiff difference_type; - typedef T value_type; - typedef const T *pointer; - typedef const T &reference; - Node *i; - inline const_iterator() : i(nullptr) {} - inline const_iterator(Node *n) : i(n) {} - inline const_iterator(const const_iterator &o) : i(o.i){} - inline const_iterator(iterator ci) : i(ci.i){} - inline const_iterator &operator=(const const_iterator &o) { i = o.i; return *this; } - inline const T &operator*() const { return i->t; } - inline const T *operator->() const { return &i->t; } - inline bool operator==(const const_iterator &o) const { return i == o.i; } - inline bool operator!=(const const_iterator &o) const { return i != o.i; } - inline const_iterator &operator++() { i = i->n; return *this; } - inline const_iterator operator++(int) { Node *n = i; i = i->n; return n; } - inline const_iterator &operator--() { i = i->p; return *this; } - inline const_iterator operator--(int) { Node *n = i; i = i->p; return n; } - inline const_iterator operator+(int j) const - { Node *n = i; if (j > 0) while (j--) n = n->n; else while (j++) n = n->p; return n; } - inline const_iterator operator-(int j) const { return operator+(-j); } - inline const_iterator &operator+=(int j) { return *this = *this + j; } - inline const_iterator &operator-=(int j) { return *this = *this - j; } - }; - friend class const_iterator; - - // stl style - inline iterator begin() { detach(); return e->n; } - inline const_iterator begin() const { return e->n; } - inline const_iterator constBegin() const { return e->n; } - inline iterator end() { detach(); return e; } - inline const_iterator end() const { return e; } - inline const_iterator constEnd() const { return e; } - iterator insert(iterator before, const T &t); - iterator erase(iterator pos); - iterator erase(iterator first, iterator last); - - // more Qt - typedef iterator Iterator; - typedef const_iterator ConstIterator; - inline int count() const { return d->size; } - inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } - inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } - T& last() { Q_ASSERT(!isEmpty()); return *(--end()); } - const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); } - inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); } - inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); } - inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; } - inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; } - - // stl compatibility - inline void push_back(const T &t) { append(t); } - inline void push_front(const T &t) { prepend(t); } - inline T& front() { return first(); } - inline const T& front() const { return first(); } - inline T& back() { return last(); } - inline const T& back() const { return last(); } - inline void pop_front() { removeFirst(); } - inline void pop_back() { removeLast(); } - inline bool empty() const { return isEmpty(); } - typedef int size_type; - typedef T value_type; - typedef value_type *pointer; - typedef const value_type *const_pointer; - typedef value_type &reference; - typedef const value_type &const_reference; - typedef qptrdiff difference_type; - - static inline QLinkedList fromStdList(const std::list &list) - { QLinkedList tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } - inline std::list toStdList() const - { std::list tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } - - - // comfort - QLinkedList &operator+=(const QLinkedList &l); - QLinkedList operator+(const QLinkedList &l) const; - inline QLinkedList &operator+=(const T &t) { append(t); return *this; } - inline QLinkedList &operator<< (const T &t) { append(t); return *this; } - inline QLinkedList &operator<<(const QLinkedList &l) { *this += l; return *this; } - -private: - inline void detach() { if (d->ref != 1) detach_helper(); } - void detach_helper(); - void freeData(QLinkedListData*); -}; - -template -inline QLinkedList::~QLinkedList() -{ - if (!d->ref.deref()) - freeData(d); -} - -template -void QLinkedList::detach_helper() -{ - union { QLinkedListData *d; Node *e; } x; - x.d = new QLinkedListData; - x.d->ref = 1; - x.d->size = d->size; - Node *original = e->n; - Node *copy = x.e; - while (original != e) { - copy->n = new Node(original->t); - copy->n->p = copy; - original = original->n; - copy = copy->n; - } - copy->n = x.e; - x.e->p = copy; - if (!d->ref.deref()) - freeData(d); - d = x.d; -} - -template -void QLinkedList::freeData(QLinkedListData *x) -{ - Node *y = reinterpret_cast(x); - Node *i = y->n; - if (x->ref == 0) { - while(i != y) { - Node *n = i; - i = i->n; - delete n; - } - delete x; - } -} - -template -void QLinkedList::clear() -{ - *this = QLinkedList(); -} - -template -QLinkedList &QLinkedList::operator=(const QLinkedList &l) -{ - if (d != l.d) { - QLinkedListData *o = l.d; - o->ref.ref(); - if (!d->ref.deref()) - freeData(d); - d = o; - } - return *this; -} - -template -bool QLinkedList::operator== (const QLinkedList &l) const -{ - if (d->size != l.d->size) - return false; - if (e == l.e) - return true; - Node *i = e->n; - Node *il = l.e->n; - while (i != e) { - if (! (i->t == il->t)) - return false; - i = i->n; - il = il->n; - } - return true; -} - -template -void QLinkedList::append(const T &t) -{ - detach(); - Node *i = new Node(t); - i->n = e; - i->p = e->p; - i->p->n = i; - e->p = i; - d->size++; -} - -template -void QLinkedList::prepend(const T &t) -{ - detach(); - Node *i = new Node(t); - i->n = e->n; - i->p = e; - i->n->p = i; - e->n = i; - d->size++; -} - -template -int QLinkedList::removeAll(const T &_t) -{ - detach(); - const T t = _t; - Node *i = e->n; - int c = 0; - while (i != e) { - if (i->t == t) { - Node *n = i; - i->n->p = i->p; - i->p->n = i->n; - i = i->n; - delete n; - c++; - } else { - i = i->n; - } - } - d->size-=c; - return c; -} - -template -bool QLinkedList::removeOne(const T &_t) -{ - detach(); - iterator it = qFind(begin(), end(), _t); - if (it != end()) { - erase(it); - return true; - } - return false; -} - -template -inline T QLinkedList::takeFirst() -{ - T t = first(); - removeFirst(); - return t; -} - -template -inline T QLinkedList::takeLast() -{ - T t = last(); - removeLast(); - return t; -} - -template -bool QLinkedList::contains(const T &t) const -{ - Node *i = e; - while ((i = i->n) != e) - if (i->t == t) - return true; - return false; -} - -template -int QLinkedList::count(const T &t) const -{ - Node *i = e; - int c = 0; - while ((i = i->n) != e) - if (i->t == t) - c++; - return c; -} - - -template -typename QLinkedList::iterator QLinkedList::insert(iterator before, const T &t) -{ - Node *i = before.i; - Node *m = new Node(t); - m->n = i; - m->p = i->p; - m->p->n = m; - i->p = m; - d->size++; - return m; -} - -template -typename QLinkedList::iterator QLinkedList::erase(typename QLinkedList::iterator afirst, - typename QLinkedList::iterator alast) -{ - while (afirst != alast) - erase(afirst++); - return alast; -} - - -template -typename QLinkedList::iterator QLinkedList::erase(iterator pos) -{ - detach(); - Node *i = pos.i; - if (i != e) { - Node *n = i; - i->n->p = i->p; - i->p->n = i->n; - i = i->n; - delete n; - d->size--; - } - return i; -} - -template -QLinkedList &QLinkedList::operator+=(const QLinkedList &l) -{ - detach(); - int n = l.d->size; - d->size += n; - Node *original = l.e->n; - while (n--) { - Node *copy = new Node(original->t); - original = original->n; - copy->n = e; - copy->p = e->p; - copy->p->n = copy; - e->p = copy; - } - return *this; -} - -template -QLinkedList QLinkedList::operator+(const QLinkedList &l) const -{ - QLinkedList n = *this; - n += l; - return n; -} - -Q_DECLARE_SEQUENTIAL_ITERATOR(LinkedList) -Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(LinkedList) - -QT_END_NAMESPACE - - -#endif // QLINKEDLIST_H diff --git a/src/core/tools/qlist.cpp b/src/core/tools/qlist.cpp index a780fc5da..5a14dd673 100644 --- a/src/core/tools/qlist.cpp +++ b/src/core/tools/qlist.cpp @@ -280,18 +280,14 @@ void **QListData::erase(void **xi) stores a list of values and provides fast index-based access as well as fast insertions and removals. - QList\, QLinkedList\, and QVector\ provide similar - functionality. Here's an overview: + QList\, and QVector\ provide similar functionality. + Here's an overview: \list - \i For most purposes, QList is the right class to use. Its - index-based API is more convenient than QLinkedList's - iterator-based API, and it is usually faster than - QVector because of the way it stores its items in - memory. It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant - time} insertions in the middle of the list and iterators to - items rather than indexes, use QLinkedList. + \i For most purposes, QList is the right class to use. It is + usually faster than QVector because of the way it stores + its items in memory. It also expands to less code in your + executable. \i If you want the items to occupy adjacent memory positions, use QVector. \endlist @@ -415,7 +411,7 @@ void **QListData::erase(void **xi) value that might not be in the valid range, check that it is less than the value returned by size() but \e not less than 0. - \sa QListIterator, QMutableListIterator, QLinkedList, QVector + \sa QListIterator, QMutableListIterator, QVector */ /*! @@ -1162,9 +1158,7 @@ void **QListData::erase(void **xi) Multiple iterators can be used on the same list. However, be aware that any non-const function call performed on the QList - will render all existing iterators undefined. If you need to keep - iterators over a long period of time, we recommend that you use - QLinkedList rather than QList. + will render all existing iterators undefined. \sa QList::const_iterator, QMutableListIterator */ @@ -1411,9 +1405,7 @@ void **QListData::erase(void **xi) Multiple iterators can be used on the same list. However, be aware that any non-const function call performed on the QList - will render all existing iterators undefined. If you need to keep - iterators over a long period of time, we recommend that you use - QLinkedList rather than QList. + will render all existing iterators undefined. \sa QList::iterator, QListIterator */ diff --git a/src/core/tools/qvarlengtharray.qdoc b/src/core/tools/qvarlengtharray.qdoc index 5bdd5c76e..895277ab3 100644 --- a/src/core/tools/qvarlengtharray.qdoc +++ b/src/core/tools/qvarlengtharray.qdoc @@ -78,7 +78,7 @@ places inside Qt and was added to Qt's public API for the convenience of advanced users. - \sa QVector, QList, QLinkedList + \sa QVector, QList */ /*! \fn QVarLengthArray::QVarLengthArray(int size) @@ -354,8 +354,7 @@ For large arrays, this operation can be slow (\l{linear time}), because it requires moving all the items in the vector by one position further in memory. If you want a container class that - provides a fast prepend() function, use QList or QLinkedList - instead. + provides a fast prepend() function, use QList instead. \sa append(), insert() */ @@ -468,9 +467,7 @@ For large arrays, this operation can be slow (\l{linear time}), because it requires moving all the items at indexes \a i and - above by one position further in memory. If you want a container - class that provides a fast insert() function, use QLinkedList - instead. + above by one position further in memory. \sa remove() */ diff --git a/src/core/tools/qvector.cpp b/src/core/tools/qvector.cpp index 573cd5c7b..b5c85a949 100644 --- a/src/core/tools/qvector.cpp +++ b/src/core/tools/qvector.cpp @@ -89,20 +89,15 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive stores its items in adjacent memory locations and provides fast index-based access. - QList\, QLinkedList\, and QVarLengthArray\ provide - similar functionality. Here's an overview: + QList\ and QVarLengthArray\ provide similar functionality. + Here's an overview: \list \i For most purposes, QList is the right class to use. Operations like prepend() and insert() are usually faster than with QVector because of the way QList stores its items in memory - (see \l{Algorithmic Complexity} for details), - and its index-based API is more convenient than QLinkedList's - iterator-based API. It also expands to less code in your - executable. - \i If you need a real linked list, with guarantees of \l{constant - time} insertions in the middle of the list and iterators to - items rather than indexes, use QLinkedList. + (see \l{Algorithmic Complexity} for details). It also expands + to less code in your executable. \i If you want the items to occupy adjacent memory positions, or if your items are larger than a pointer and you want to avoid the overhead of allocating them on the heap individually at @@ -171,7 +166,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive (\l{linear time}) for large vectors, because they require moving many items in the vector by one position in memory. If you want a container class that provides fast insertion/removal in the middle, use - QList or QLinkedList instead. + QList instead. Unlike plain C++ arrays, QVectors can be resized at any time by calling resize(). If the new size is larger than the old size, @@ -210,7 +205,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive with references to its own values. Doing so will cause your application to abort with an error message. - \sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList + \sa QVectorIterator, QMutableVectorIterator, QList */ /*! @@ -486,8 +481,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive For large vectors, this operation can be slow (\l{linear time}), because it requires moving all the items in the vector by one position further in memory. If you want a container class that - provides a fast prepend() function, use QList or QLinkedList - instead. + provides a fast prepend() function, use QList instead. \sa append(), insert() */ @@ -503,9 +497,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive For large vectors, this operation can be slow (\l{linear time}), because it requires moving all the items at indexes \a i and - above by one position further in memory. If you want a container - class that provides a fast insert() function, use QLinkedList - instead. + above by one position further in memory. \sa append(), prepend(), remove() */ diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 4d70a0e9d..528d2aec2 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -2482,7 +2482,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutLastVertex[orientation]); } - QLinkedList remainingConstraints; + QList remainingConstraints; for (int i = 0; i < constraints[orientation].count(); ++i) { remainingConstraints += constraints[orientation].at(i); } @@ -2501,7 +2501,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) do { dirty = false; - QLinkedList::iterator it = remainingConstraints.begin(); + QList::iterator it = remainingConstraints.begin(); while (it != remainingConstraints.end()) { QSimplexConstraint *c = *it; bool match = false; @@ -2541,7 +2541,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) if (!remainingConstraints.isEmpty()) { QList nonTrunkConstraints; - QLinkedList::iterator it = remainingConstraints.begin(); + QList::iterator it = remainingConstraints.begin(); while (it != remainingConstraints.end()) { nonTrunkConstraints += *it; ++it; diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h index 47c45cb56..af6e6faa0 100644 --- a/src/gui/itemviews/qtableview_p.h +++ b/src/gui/itemviews/qtableview_p.h @@ -34,7 +34,6 @@ // #include -#include #include #include #include @@ -92,7 +91,7 @@ public: void updateRemovedRows(int start, int end); void updateRemovedColumns(int start, int end); - typedef QLinkedList SpanList; + typedef QList SpanList; SpanList spans; //lists of all spans private: //the indexes are negative so the QMap::lowerBound do what i need. diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp index 7921d7755..b35fca0bc 100644 --- a/src/script/api/qscriptvalueiterator.cpp +++ b/src/script/api/qscriptvalueiterator.cpp @@ -26,7 +26,7 @@ #include "qscriptengine.h" #include "qscriptengine_p.h" #include "qscriptvalue_p.h" -#include "qlinkedlist.h" +#include "qlist.h" #include "JSObject.h" @@ -123,9 +123,9 @@ public: } QScriptValue objectValue; - QLinkedList propertyNames; - QLinkedList::iterator it; - QLinkedList::iterator current; + QList propertyNames; + QList::iterator it; + QList::iterator current; bool initialized; }; diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index a53c4bc9d..f29203307 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -358,8 +358,6 @@ static const struct ClassTblData { { QLatin1String("QLineEdit"), QLatin1String("QtGui/qlineedit.h") }, { QLatin1String("QLineF"), QLatin1String("QtCore/qline.h") }, { QLatin1String("QLinearGradient"), QLatin1String("QtGui/qbrush.h") }, - { QLatin1String("QLinkedList"), QLatin1String("QtCore/qlinkedlist.h") }, - { QLatin1String("QLinkedListData"), QLatin1String("QtCore/qlinkedlist.h") }, { QLatin1String("QList"), QLatin1String("QtCore/qlist.h") }, { QLatin1String("QListData"), QLatin1String("QtCore/qlist.h") }, { QLatin1String("QListView"), QLatin1String("QtGui/qlistview.h") }, diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index ebf83722b..42d9e231d 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -167,7 +167,7 @@ private slots: void status_QHash_QMap(); - void status_QLinkedList_QList_QVector(); + void status_QList_QVector(); void streamToAndFromQByteArray(); @@ -2815,17 +2815,6 @@ void tst_QDataStream::status_QHash_QMap() QCOMPARE(list, expectedList); \ } \ { \ - LinkedList expectedLinkedList; \ - for (int i = 0; i < expectedList.count(); ++i) \ - expectedLinkedList << expectedList.at(i); \ - QByteArray ba = byteArray; \ - QDataStream stream(&ba, QIODevice::ReadOnly); \ - stream >> linkedList; \ - QCOMPARE((int)stream.status(), (int)expectedStatus); \ - QCOMPARE(linkedList.size(), expectedLinkedList.size()); \ - QCOMPARE(linkedList, expectedLinkedList); \ - } \ - { \ Vector expectedVector; \ for (int i = 0; i < expectedList.count(); ++i) \ expectedVector << expectedList.at(i); \ @@ -2837,12 +2826,10 @@ void tst_QDataStream::status_QHash_QMap() QCOMPARE(vector, expectedVector); \ } -void tst_QDataStream::status_QLinkedList_QList_QVector() +void tst_QDataStream::status_QList_QVector() { - typedef QLinkedList LinkedList; typedef QList List; typedef QVector Vector; - LinkedList linkedList; List list; Vector vector; diff --git a/util/qlalr/cppgenerator.cpp b/util/qlalr/cppgenerator.cpp index 8aff5f0b4..b486890f3 100644 --- a/util/qlalr/cppgenerator.cpp +++ b/util/qlalr/cppgenerator.cpp @@ -205,7 +205,7 @@ void CppGenerator::operator () () << endl; } - QBitArray used_rules (grammar.rules.count ()); + QBitArray used_rules (grammar.rules.size ()); int q = 0; for (StatePointer state = aut.states.begin (); state != aut.states.end (); ++state, ++q) diff --git a/util/qlalr/lalr.cpp b/util/qlalr/lalr.cpp index b4eaa44e8..d198a9b0c 100644 --- a/util/qlalr/lalr.cpp +++ b/util/qlalr/lalr.cpp @@ -313,7 +313,7 @@ QPair Automaton::internState (const State &state) struct _Bucket { - QLinkedList items; + QList items; void insert (ItemPointer item) { items.push_back (item); } @@ -322,7 +322,7 @@ struct _Bucket { State st (aut->_M_grammar); - for (QLinkedList::iterator item = items.begin (); item != items.end (); ++item) + for (QList::iterator item = items.begin (); item != items.end (); ++item) st.insert ((*item)->next ()); return st; diff --git a/util/qlalr/lalr.h b/util/qlalr/lalr.h index 6e9dff423..ece7e5897 100644 --- a/util/qlalr/lalr.h +++ b/util/qlalr/lalr.h @@ -27,11 +27,12 @@ #include #include #include -#include #include #include #include +#include + QT_BEGIN_NAMESPACE class Rule; @@ -127,21 +128,21 @@ public: }; // names -typedef QLinkedList::iterator Name; -typedef QLinkedList NameList; +typedef std::vector::iterator Name; +typedef std::vector NameList; typedef OrderedSet NameSet; // items -typedef QLinkedList ItemList; +typedef std::vector ItemList; typedef ItemList::iterator ItemPointer; // rules -typedef QLinkedList debug_infot; +typedef std::vector debug_infot; typedef debug_infot::iterator RulePointer; typedef QMultiMap RuleMap; // states -typedef QLinkedList StateList; +typedef std::vector StateList; typedef StateList::iterator StatePointer; // arrows @@ -239,7 +240,7 @@ class Node public: typedef OrderedSet > Repository; typedef typename Repository::iterator iterator; - typedef typename QLinkedList::iterator edge_iterator; + typedef typename std::vector::iterator edge_iterator; public: static iterator get (_Tp data); @@ -277,7 +278,7 @@ public: // attributes mutable bool root; mutable int dfn; mutable _Tp data; - mutable QLinkedList outs; + mutable std::vector outs; protected: inline Node () {} @@ -299,7 +300,7 @@ typename Node<_Tp>::iterator Node<_Tp>::get (_Tp data) } template -QPair::iterator>::iterator, bool> Node<_Tp>::insertEdge (typename Node<_Tp>::iterator other) const +QPair::iterator>::iterator, bool> Node<_Tp>::insertEdge (typename Node<_Tp>::iterator other) const { edge_iterator it = qFind (outs.begin (), outs.end (), other); @@ -335,7 +336,7 @@ public: QString decl_file_name; QString impl_file_name; QString token_prefix; - QLinkedList names; + std::vector names; Name start; NameSet terminals; NameSet non_terminals; diff --git a/util/qlalr/main.cpp b/util/qlalr/main.cpp index 9ca6db351..6788c20f4 100644 --- a/util/qlalr/main.cpp +++ b/util/qlalr/main.cpp @@ -104,7 +104,7 @@ int main (int argc, char *argv[]) if (! p.parse (file_name)) exit (EXIT_FAILURE); - if (grammar.rules.isEmpty ()) + if (grammar.rules.size() == 0) { qerr << "*** Fatal. No rules!" << endl; exit (EXIT_FAILURE); -- 2.11.0