1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtCore module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qlinkedlist.h"
46 const QLinkedListData QLinkedListData::shared_null = {
47 const_cast<QLinkedListData *>(&QLinkedListData::shared_null),
48 const_cast<QLinkedListData *>(&QLinkedListData::shared_null),
49 Q_REFCOUNT_INITIALIZE_STATIC, 0, true
52 /*! \class QLinkedList
53 \brief The QLinkedList class is a template class that provides linked lists.
60 QLinkedList\<T\> is one of Qt's generic \l{container classes}. It
61 stores a list of values and provides iterator-based access as
62 well as \l{constant time} insertions and removals.
64 QList\<T\>, QLinkedList\<T\>, and QVector\<T\> provide similar
65 functionality. Here's an overview:
68 \li For most purposes, QList is the right class to use. Its
69 index-based API is more convenient than QLinkedList's
70 iterator-based API, and it is usually faster than
71 QVector because of the way it stores its items in
72 memory (see \l{Algorithmic Complexity} for details).
73 It also expands to less code in your executable.
74 \li If you need a real linked list, with guarantees of \l{constant
75 time} insertions in the middle of the list and iterators to
76 items rather than indexes, use QLinkedList.
77 \li If you want the items to occupy adjacent memory positions,
81 Here's an example of a QLinkedList that stores integers and a
82 QLinkedList that stores QTime values:
84 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 0
86 QLinkedList stores a list of items. The default constructor
87 creates an empty list. To insert items into the list, you can use
90 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 1
92 If you want to get the first or last item in a linked list, use
93 first() or last(). If you want to remove an item from either end
94 of the list, use removeFirst() or removeLast(). If you want to
95 remove all occurrences of a given value in the list, use
98 A common requirement is to remove the first or last item in the
99 list and do something with it. For this, QLinkedList provides
100 takeFirst() and takeLast(). Here's a loop that removes the items
101 from a list one at a time and calls \c delete on them:
102 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 2
104 QLinkedList's value type must be an \l {assignable data type}. This
105 covers most data types that are commonly used, but the compiler
106 won't let you, for example, store a QWidget as a value; instead,
107 store a QWidget *. A few functions have additional requirements;
108 for example, contains() and removeAll() expect the value type to
109 support \c operator==(). These requirements are documented on a
112 If you want to insert, modify, or remove items in the middle of
113 the list, you must use an iterator. QLinkedList provides both
114 \l{Java-style iterators} (QLinkedListIterator and
115 QMutableLinkedListIterator) and \l{STL-style iterators}
116 (QLinkedList::const_iterator and QLinkedList::iterator). See the
117 documentation for these classes for details.
119 \sa QLinkedListIterator, QMutableLinkedListIterator, QList, QVector
122 /*! \fn QLinkedList::QLinkedList()
124 Constructs an empty list.
127 /*! \fn QLinkedList::QLinkedList(const QLinkedList<T> &other)
129 Constructs a copy of \a other.
131 This operation occurs in \l{constant time}, because QLinkedList
132 is \l{implicitly shared}. This makes returning a QLinkedList from
133 a function very fast. If a shared instance is modified, it will
134 be copied (copy-on-write), and this takes \l{linear time}.
139 /*! \fn QLinkedList::~QLinkedList()
141 Destroys the list. References to the values in the list, and all
142 iterators over this list, become invalid.
145 /*! \fn QLinkedList<T> &QLinkedList::operator=(const QLinkedList<T> &other)
147 Assigns \a other to this list and returns a reference to this
151 /*! \fn void QLinkedList::swap(QLinkedList<T> &other)
154 Swaps list \a other with this list. This operation is very
155 fast and never fails.
158 /*! \fn bool QLinkedList::operator==(const QLinkedList<T> &other) const
160 Returns true if \a other is equal to this list; otherwise returns
163 Two lists are considered equal if they contain the same values in
166 This function requires the value type to implement \c
172 /*! \fn bool QLinkedList::operator!=(const QLinkedList<T> &other) const
174 Returns true if \a other is not equal to this list; otherwise
177 Two lists are considered equal if they contain the same values in
180 This function requires the value type to implement \c
186 /*! \fn int QLinkedList::size() const
188 Returns the number of items in the list.
190 \sa isEmpty(), count()
193 /*! \fn void QLinkedList::detach()
198 /*! \fn bool QLinkedList::isDetached() const
203 /*! \fn void QLinkedList::setSharable(bool sharable)
208 /*! \fn bool QLinkedList::isSharedWith(const QLinkedList<T> &other) const
213 /*! \fn bool QLinkedList::isEmpty() const
215 Returns true if the list contains no items; otherwise returns
221 /*! \fn void QLinkedList::clear()
223 Removes all the items in the list.
228 /*! \fn void QLinkedList::append(const T &value)
230 Inserts \a value at the end of the list.
233 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 3
235 This is the same as list.insert(end(), \a value).
237 \sa operator<<(), prepend(), insert()
240 /*! \fn void QLinkedList::prepend(const T &value)
242 Inserts \a value at the beginning of the list.
245 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 4
247 This is the same as list.insert(begin(), \a value).
249 \sa append(), insert()
252 /*! \fn int QLinkedList::removeAll(const T &value)
254 Removes all occurrences of \a value in the list.
257 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 5
259 This function requires the value type to have an implementation of
266 \fn bool QLinkedList::removeOne(const T &value)
269 Removes the first occurrences of \a value in the list. Returns true on
270 success; otherwise returns false.
273 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 6
275 This function requires the value type to have an implementation of
281 /*! \fn bool QLinkedList::contains(const T &value) const
283 Returns true if the list contains an occurrence of \a value;
284 otherwise returns false.
286 This function requires the value type to have an implementation of
289 \sa QLinkedListIterator::findNext(), QLinkedListIterator::findPrevious()
292 /*! \fn int QLinkedList::count(const T &value) const
294 Returns the number of occurrences of \a value in the list.
296 This function requires the value type to have an implementation of
302 /*! \fn bool QLinkedList::startsWith(const T &value) const
305 Returns true if the list is not empty and its first
306 item is equal to \a value; otherwise returns false.
308 \sa isEmpty(), first()
311 /*! \fn bool QLinkedList::endsWith(const T &value) const
314 Returns true if the list is not empty and its last
315 item is equal to \a value; otherwise returns false.
317 \sa isEmpty(), last()
320 /*! \fn QLinkedList::iterator QLinkedList::begin()
322 Returns an \l{STL-style iterator} pointing to the first item in
325 \sa constBegin(), end()
328 /*! \fn QLinkedList::const_iterator QLinkedList::begin() const
333 /*! \fn QLinkedList::const_iterator QLinkedList::cbegin() const
336 Returns a const \l{STL-style iterator} pointing to the first item
342 /*! \fn QLinkedList::const_iterator QLinkedList::constBegin() const
344 Returns a const \l{STL-style iterator} pointing to the first item
347 \sa begin(), constEnd()
350 /*! \fn QLinkedList::iterator QLinkedList::end()
352 Returns an \l{STL-style iterator} pointing to the imaginary item
353 after the last item in the list.
355 \sa begin(), constEnd()
358 /*! \fn QLinkedList::const_iterator QLinkedList::end() const
363 /*! \fn QLinkedList::const_iterator QLinkedList::cend() const
366 Returns a const \l{STL-style iterator} pointing to the imaginary
367 item after the last item in the list.
372 /*! \fn QLinkedList::const_iterator QLinkedList::constEnd() const
374 Returns a const \l{STL-style iterator} pointing to the imaginary
375 item after the last item in the list.
377 \sa constBegin(), end()
380 /*! \fn QLinkedList::iterator QLinkedList::insert(iterator before, const T &value)
382 Inserts \a value in front of the item pointed to by the iterator
383 \a before. Returns an iterator pointing at the inserted item.
388 /*! \fn QLinkedList::iterator QLinkedList::erase(iterator pos)
390 Removes the item pointed to by the iterator \a pos from the list,
391 and returns an iterator to the next item in the list (which may be
397 /*! \fn QLinkedList::iterator QLinkedList::erase(iterator begin, iterator end)
401 Removes all the items from \a begin up to (but not including) \a
405 /*! \typedef QLinkedList::Iterator
407 Qt-style synonym for QLinkedList::iterator.
410 /*! \typedef QLinkedList::ConstIterator
412 Qt-style synonym for QLinkedList::const_iterator.
416 \typedef QLinkedList::size_type
418 Typedef for int. Provided for STL compatibility.
422 \typedef QLinkedList::value_type
424 Typedef for T. Provided for STL compatibility.
428 \typedef QLinkedList::pointer
430 Typedef for T *. Provided for STL compatibility.
434 \typedef QLinkedList::const_pointer
436 Typedef for const T *. Provided for STL compatibility.
440 \typedef QLinkedList::reference
442 Typedef for T &. Provided for STL compatibility.
446 \typedef QLinkedList::const_reference
448 Typedef for const T &. Provided for STL compatibility.
452 \typedef QLinkedList::difference_type
454 Typedef for ptrdiff_t. Provided for STL compatibility.
457 /*! \fn int QLinkedList::count() const
462 /*! \fn T& QLinkedList::first()
464 Returns a reference to the first item in the list. This function
465 assumes that the list isn't empty.
467 \sa last(), isEmpty()
470 /*! \fn const T& QLinkedList::first() const
475 /*! \fn T& QLinkedList::last()
477 Returns a reference to the last item in the list. This function
478 assumes that the list isn't empty.
480 \sa first(), isEmpty()
483 /*! \fn const T& QLinkedList::last() const
488 /*! \fn void QLinkedList::removeFirst()
490 Removes the first item in the list.
492 This is the same as erase(begin()).
494 \sa removeLast(), erase()
497 /*! \fn void QLinkedList::removeLast()
499 Removes the last item in the list.
501 \sa removeFirst(), erase()
504 /*! \fn T QLinkedList::takeFirst()
506 Removes the first item in the list and returns it.
508 If you don't use the return value, removeFirst() is more
511 \sa takeLast(), removeFirst()
514 /*! \fn T QLinkedList::takeLast()
516 Removes the last item in the list and returns it.
518 If you don't use the return value, removeLast() is more
521 \sa takeFirst(), removeLast()
524 /*! \fn void QLinkedList::push_back(const T &value)
526 This function is provided for STL compatibility. It is equivalent
530 /*! \fn void QLinkedList::push_front(const T &value)
532 This function is provided for STL compatibility. It is equivalent
533 to prepend(\a value).
536 /*! \fn T& QLinkedList::front()
538 This function is provided for STL compatibility. It is equivalent
542 /*! \fn const T& QLinkedList::front() const
547 /*! \fn T& QLinkedList::back()
549 This function is provided for STL compatibility. It is equivalent
553 /*! \fn const T& QLinkedList::back() const
558 /*! \fn void QLinkedList::pop_front()
560 This function is provided for STL compatibility. It is equivalent
564 /*! \fn void QLinkedList::pop_back()
566 This function is provided for STL compatibility. It is equivalent
570 /*! \fn bool QLinkedList::empty() const
572 This function is provided for STL compatibility. It is equivalent
573 to isEmpty() and returns true if the list is empty.
576 /*! \fn QLinkedList<T> &QLinkedList::operator+=(const QLinkedList<T> &other)
578 Appends the items of the \a other list to this list and returns a
579 reference to this list.
581 \sa operator+(), append()
584 /*! \fn void QLinkedList::operator+=(const T &value)
588 Appends \a value to the list.
591 /*! \fn QLinkedList<T> QLinkedList::operator+(const QLinkedList<T> &other) const
593 Returns a list that contains all the items in this list followed
594 by all the items in the \a other list.
599 /*! \fn QLinkedList<T> &QLinkedList::operator<<(const QLinkedList<T> &other)
601 Appends the items of the \a other list to this list and returns a
602 reference to this list.
604 \sa operator+=(), append()
607 /*! \fn QLinkedList<T> &QLinkedList::operator<<(const T &value)
611 Appends \a value to the list.
614 /*! \class QLinkedList::iterator
615 \brief The QLinkedList::iterator class provides an STL-style non-const iterator for QLinkedList.
617 QLinkedList features both \l{STL-style iterators} and
618 \l{Java-style iterators}. The STL-style iterators are more
619 low-level and more cumbersome to use; on the other hand, they are
620 slightly faster and, for developers who already know STL, have
621 the advantage of familiarity.
623 QLinkedList\<T\>::iterator allows you to iterate over a
624 QLinkedList\<T\> and to modify the list item associated with the
625 iterator. If you want to iterate over a const QLinkedList, use
626 QLinkedList::const_iterator instead. It is generally good
627 practice to use QLinkedList::const_iterator on a non-const
628 QLinkedList as well, unless you need to change the QLinkedList
629 through the iterator. Const iterators are slightly faster, and
630 can improve code readability.
632 The default QLinkedList::iterator constructor creates an
633 uninitialized iterator. You must initialize it using a
634 function like QLinkedList::begin(), QLinkedList::end(), or
635 QLinkedList::insert() before you can start iterating. Here's a
636 typical loop that prints all the items stored in a list:
638 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 7
640 STL-style iterators can be used as arguments to \l{generic
641 algorithms}. For example, here's how to find an item in the list
642 using the qFind() algorithm:
644 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 8
646 Let's see a few examples of things we can do with a
647 QLinkedList::iterator that we cannot do with a QLinkedList::const_iterator.
648 Here's an example that increments every value stored in a
649 QLinkedList\<int\> by 2:
651 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 9
653 Here's an example that removes all the items that start with an
654 underscore character in a QLinkedList\<QString\>:
656 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 10
658 The call to QLinkedList::erase() removes the item pointed to by
659 the iterator from the list, and returns an iterator to the next
660 item. Here's another way of removing an item while iterating:
662 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 11
664 It might be tempting to write code like this:
666 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 12
668 However, this will potentially crash in \c{++i}, because \c i is
669 a dangling iterator after the call to erase().
671 Multiple iterators can be used on the same list. If you add items
672 to the list, existing iterators will remain valid. If you remove
673 items from the list, iterators that point to the removed items
674 will become dangling iterators. However, because of how \l{implicit
675 sharing} works, you must not take a copy of a container while
676 iterators are active on that container.
678 \sa QLinkedList::const_iterator, QMutableLinkedListIterator
681 /*! \fn QLinkedList::iterator::iterator()
683 Constructs an uninitialized iterator.
685 Functions like operator*() and operator++() should not be called
686 on an uninitialized iterator. Use operator=() to assign a value
687 to it before using it.
689 \sa QLinkedList::begin() QLinkedList::end()
692 /*! \fn QLinkedList::iterator::iterator(Node *node)
697 /*! \typedef QLinkedList::iterator::iterator_category
702 /*! \typedef QLinkedList::iterator::difference_type
707 /*! \typedef QLinkedList::iterator::value_type
712 /*! \typedef QLinkedList::iterator::pointer
717 /*! \typedef QLinkedList::iterator::reference
722 /*! \fn QLinkedList::iterator::iterator(const iterator &other)
724 Constructs a copy of \a other.
727 /*! \fn QLinkedList::iterator &QLinkedList::iterator::operator=(const iterator &other)
729 Assigns \a other to this iterator.
732 /*! \fn T &QLinkedList::iterator::operator*() const
734 Returns a modifiable reference to the current item.
736 You can change the value of an item by using operator*() on the
737 left side of an assignment, for example:
739 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 13
744 /*! \fn T *QLinkedList::iterator::operator->() const
746 Returns a pointer to the current item.
752 \fn bool QLinkedList::iterator::operator==(const iterator &other) const
753 \fn bool QLinkedList::iterator::operator==(const const_iterator &other) const
755 Returns true if \a other points to the same item as this
756 iterator; otherwise returns false.
762 \fn bool QLinkedList::iterator::operator!=(const iterator &other) const
763 \fn bool QLinkedList::iterator::operator!=(const const_iterator &other) const
765 Returns true if \a other points to a different item than this
766 iterator; otherwise returns false.
771 /*! \fn QLinkedList::iterator &QLinkedList::iterator::operator++()
773 The prefix ++ operator (\c{++it}) advances the iterator to the
774 next item in the list and returns an iterator to the new current
777 Calling this function on QLinkedList::end() leads to undefined
783 /*! \fn QLinkedList::iterator QLinkedList::iterator::operator++(int)
787 The postfix ++ operator (\c{it++}) advances the iterator to the
788 next item in the list and returns an iterator to the previously
792 /*! \fn QLinkedList::iterator &QLinkedList::iterator::operator--()
794 The prefix -- operator (\c{--it}) makes the preceding item
795 current and returns an iterator to the new current item.
797 Calling this function on QLinkedList::begin() leads to undefined
803 /*! \fn QLinkedList::iterator QLinkedList::iterator::operator--(int)
807 The postfix -- operator (\c{it--}) makes the preceding item
808 current and returns an iterator to the previously current item.
811 /*! \fn QLinkedList::iterator QLinkedList::iterator::operator+(int j) const
813 Returns an iterator to the item at \a j positions forward from
814 this iterator. (If \a j is negative, the iterator goes backward.)
816 This operation can be slow for large \a j values.
822 /*! \fn QLinkedList::iterator QLinkedList::iterator::operator-(int j) const
824 Returns an iterator to the item at \a j positions backward from
825 this iterator. (If \a j is negative, the iterator goes forward.)
827 This operation can be slow for large \a j values.
832 /*! \fn QLinkedList::iterator &QLinkedList::iterator::operator+=(int j)
834 Advances the iterator by \a j items. (If \a j is negative, the
835 iterator goes backward.)
837 \sa operator-=(), operator+()
840 /*! \fn QLinkedList::iterator &QLinkedList::iterator::operator-=(int j)
842 Makes the iterator go back by \a j items. (If \a j is negative,
843 the iterator goes forward.)
845 \sa operator+=(), operator-()
848 /*! \class QLinkedList::const_iterator
849 \brief The QLinkedList::const_iterator class provides an STL-style const iterator for QLinkedList.
851 QLinkedList features both \l{STL-style iterators} and
852 \l{Java-style iterators}. The STL-style iterators are more
853 low-level and more cumbersome to use; on the other hand, they are
854 slightly faster and, for developers who already know STL, have
855 the advantage of familiarity.
857 QLinkedList\<T\>::const_iterator allows you to iterate over a
858 QLinkedList\<T\>. If you want modify the QLinkedList as you iterate
859 over it, you must use QLinkedList::iterator instead. It is
860 generally good practice to use QLinkedList::const_iterator on a
861 non-const QLinkedList as well, unless you need to change the
862 QLinkedList through the iterator. Const iterators are slightly
863 faster, and can improve code readability.
865 The default QLinkedList::const_iterator constructor creates an
866 uninitialized iterator. You must initialize it using a function
867 like QLinkedList::constBegin(), QLinkedList::constEnd(), or
868 QLinkedList::insert() before you can start iterating. Here's a
869 typical loop that prints all the items stored in a list:
871 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 14
873 STL-style iterators can be used as arguments to \l{generic
874 algorithms}. For example, here's how to find an item in the list
875 using the qFind() algorithm:
877 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 15
879 Multiple iterators can be used on the same list. If you add items
880 to the list, existing iterators will remain valid. If you remove
881 items from the list, iterators that point to the removed items
882 will become dangling iterators.
884 \sa QLinkedList::iterator, QLinkedListIterator
887 /*! \fn QLinkedList::const_iterator::const_iterator()
889 Constructs an uninitialized iterator.
891 Functions like operator*() and operator++() should not be called
892 on an uninitialized iterator. Use operator=() to assign a value
893 to it before using it.
895 \sa QLinkedList::constBegin() QLinkedList::constEnd()
898 /*! \fn QLinkedList::const_iterator::const_iterator(Node *node)
903 /*! \typedef QLinkedList::const_iterator::iterator_category
908 /*! \typedef QLinkedList::const_iterator::difference_type
913 /*! \typedef QLinkedList::const_iterator::value_type
918 /*! \typedef QLinkedList::const_iterator::pointer
923 /*! \typedef QLinkedList::const_iterator::reference
928 /*! \fn QLinkedList::const_iterator::const_iterator(const const_iterator &other)
930 Constructs a copy of \a other.
933 /*! \fn QLinkedList::const_iterator::const_iterator(iterator other)
935 Constructs a copy of \a other.
938 /*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator=( \
939 const const_iterator &other)
941 Assigns \a other to this iterator.
944 /*! \fn const T &QLinkedList::const_iterator::operator*() const
946 Returns a reference to the current item.
951 /*! \fn const T *QLinkedList::const_iterator::operator->() const
953 Returns a pointer to the current item.
958 /*! \fn bool QLinkedList::const_iterator::operator==(const const_iterator &other) const
960 Returns true if \a other points to the same item as this
961 iterator; otherwise returns false.
966 /*! \fn bool QLinkedList::const_iterator::operator!=(const const_iterator &other) const
968 Returns true if \a other points to a different item than this
969 iterator; otherwise returns false.
974 /*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator++()
976 The prefix ++ operator (\c{++it}) advances the iterator to the
977 next item in the list and returns an iterator to the new current
980 Calling this function on QLinkedList::constEnd() leads to
986 /*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator++(int)
990 The postfix ++ operator (\c{it++}) advances the iterator to the
991 next item in the list and returns an iterator to the previously
995 /*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator--()
997 The prefix -- operator (\c{--it}) makes the preceding item
998 current and returns an iterator to the new current item.
1000 Calling this function on QLinkedList::begin() leads to undefined
1006 /*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator--(int)
1010 The postfix -- operator (\c{it--}) makes the preceding item
1011 current and returns an iterator to the previously current item.
1014 /*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator+(int j) const
1016 Returns an iterator to the item at \a j positions forward from
1017 this iterator. (If \a j is negative, the iterator goes backward.)
1019 This operation can be slow for large \a j values.
1024 /*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator-(int j) const
1026 This function returns an iterator to the item at \a j positions backward from
1027 this iterator. (If \a j is negative, the iterator goes forward.)
1029 This operation can be slow for large \a j values.
1034 /*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator+=(int j)
1036 Advances the iterator by \a j items. (If \a j is negative, the
1037 iterator goes backward.)
1039 This operation can be slow for large \a j values.
1041 \sa operator-=(), operator+()
1044 /*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator-=(int j)
1046 Makes the iterator go back by \a j items. (If \a j is negative,
1047 the iterator goes forward.)
1049 This operation can be slow for large \a j values.
1051 \sa operator+=(), operator-()
1054 /*! \fn QDataStream &operator<<(QDataStream &out, const QLinkedList<T> &list)
1055 \relates QLinkedList
1057 Writes the linked list \a list to stream \a out.
1059 This function requires the value type to implement \c
1062 \sa \link datastreamformat.html Format of the QDataStream operators \endlink
1065 /*! \fn QDataStream &operator>>(QDataStream &in, QLinkedList<T> &list)
1066 \relates QLinkedList
1068 Reads a linked list from stream \a in into \a list.
1070 This function requires the value type to implement \c operator>>().
1072 \sa \link datastreamformat.html Format of the QDataStream operators \endlink
1077 \fn QLinkedList<T> QLinkedList<T>::fromStdList(const std::list<T> &list)
1079 Returns a QLinkedList object with the data contained in \a list.
1080 The order of the elements in the QLinkedList is the same as in \a
1085 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 16
1092 \fn std::list<T> QLinkedList<T>::toStdList() const
1094 Returns a std::list object with the data contained in this
1095 QLinkedList. Example:
1097 \snippet doc/src/snippets/code/src_corelib_tools_qlinkedlist.cpp 17