QLinkedList Class▲
-
Header: QLinkedList
-
qmake: QT += core
-
Group: QLinkedList is part of tools, https://
Detailed Description▲
https://<T> is one of Qt's generic https://. It stores a list of values and provides iterator-based access as well as https:// insertions and removals.
https://<T>, https://<T>, and https://<T> provide similar functionality. Here's an overview:
-
For most purposes, https:// is the right class to use. Its index-based API is more convenient than https://'s iterator-based API, and it is usually faster than https:// because of the way it stores its items in memory (see https:// for details). It also expands to less code in your executable.
-
If you need a real linked list, with guarantees of https:// insertions in the middle of the list and iterators to items rather than indexes, use https://.
-
If you want the items to occupy adjacent memory positions, use https://.
Here's an example of a https:// that stores integers and a https:// that stores QTime values:
QLinkedList<int> integerList;
QLinkedList<QTime> timeList;https:// stores a list of items. The default constructor creates an empty list. To insert items into the list, you can use operator<<():
QLinkedList<QString> list;
list << "one" << "two" << "three";
// list: ["one", "two", "three"]If you want to get the first or last item in a linked list, use https://() or https://(). If you want to remove an item from either end of the list, use https://() or https://(). If you want to remove all occurrences of a given value in the list, use https://().
A common requirement is to remove the first or last item in the list and do something with it. For this, https:// provides https://() and https://(). Here's a loop that removes the items from a list one at a time and calls delete on them:
QLinkedList<QWidget *> list;
...
while (!list.isEmpty())
delete list.takeFirst();https://'s value type must be an https://. 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, https://() and https://() expect the value type to support 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. https:// provides both https:// (QLinkedListIterator and QMutableLinkedListIterator) and https:// (https:// and https://). See the documentation for these classes for details.
See Also▲
See also QLinkedListIterator, QMutableLinkedListIterator, https://, https://
Member Type Documentation▲
QLinkedList::ConstIterator▲
Qt-style synonym for https://.
QLinkedList::Iterator▲
Qt-style synonym for https://.
QLinkedList::const_pointer▲
Typedef for const T *. Provided for STL compatibility.
QLinkedList::const_reference▲
Typedef for const T &. Provided for STL compatibility.
[since 5.6] QLinkedList::const_reverse_iterator▲
The QLinkedList::const_reverse_iterator typedef provides an STL-style const reverse iterator for https://.
It is simply a typedef for std::reverse_iterator<QLinkedList::const_iterator>.
Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read https://.
This typedef was introduced in Qt 5.6.
See Also▲
See also QLinkedList::rbegin(), QLinkedList::rend(), https://, https://
QLinkedList::difference_type▲
Typedef for ptrdiff_t. Provided for STL compatibility.
QLinkedList::pointer▲
Typedef for T *. Provided for STL compatibility.
QLinkedList::reference▲
Typedef for T &. Provided for STL compatibility.
[since 5.6] QLinkedList::reverse_iterator▲
The QLinkedList::reverse_iterator typedef provides an STL-style non-const reverse iterator for https://.
It is simply a typedef for std::reverse_iterator<QLinkedList::iterator>.
Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read https://.
This typedef was introduced in Qt 5.6.
See Also▲
See also QLinkedList::rbegin(), QLinkedList::rend(), https://, https://
QLinkedList::size_type▲
Typedef for int. Provided for STL compatibility.
QLinkedList::value_type▲
Typedef for T. Provided for STL compatibility.
Member Function Documentation▲
QLinkedList::QLinkedList()▲
Constructs an empty list.
[since 5.2] QLinkedList::QLinkedList(QLinkedList<T> &&other)▲
Move-constructs a https:// instance, making it point at the same object that other was pointing to.
This function was introduced in Qt 5.2.
[default] QLinkedList::QLinkedList(const QLinkedList<T> &other)▲
Constructs a copy of other.
This operation occurs in https://, because https:// is https://. This makes returning a https:// from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes https://.
See Also▲
See also https://()
[default, since 5.2] QLinkedList::QLinkedList(std::initializer_list<T> list)▲
Constructs a list from the std::initializer_list specified by list.
This constructor is only enabled if the compiler supports C++11 initializer lists.
This function was introduced in Qt 5.2.
[default] QLinkedList::~QLinkedList()▲
Destroys the list. References to the values in the list, and all iterators over this list, become invalid.
void QLinkedList::append(const T &value)▲
Inserts value at the end of the list.
Example:
QLinkedList<QString> list;
list.append("one");
list.append("two");
list.append("three");
// list: ["one", "two", "three"]This is the same as list.insert(end(), value).
See Also▲
See also https://(), https://(), insert()
T &QLinkedList::back()▲
This function is provided for STL compatibility. It is equivalent to https://().
const T &QLinkedList::back() const▲
This is an overloaded function.
QLinkedList::iterator QLinkedList::begin()▲
QLinkedList::const_iterator QLinkedList::begin() const▲
This is an overloaded function.
void QLinkedList::clear()▲
bool QLinkedList::contains(const T &value) const▲
Returns true if the list contains an occurrence of value; otherwise returns false.
This function requires the value type to have an implementation of operator==().
See Also▲
See also QLinkedListIterator::findNext(), QLinkedListIterator::findPrevious()
int QLinkedList::count(const T &value) const▲
Returns the number of occurrences of value in the list.
This function requires the value type to have an implementation of operator==().
See Also▲
See also https://()
int QLinkedList::count() const▲
Same as https://().
bool QLinkedList::empty() const▲
This function is provided for STL compatibility. It is equivalent to https://() and returns true if the list is empty.
[since 4.5] bool QLinkedList::endsWith(const T &value) const▲
Returns true if the list is not empty and its last item is equal to value; otherwise returns false.
This function was introduced in Qt 4.5.
See Also▲
See also https://(), https://()
QLinkedList::iterator QLinkedList::erase(QLinkedList::iterator pos)▲
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next item in the list (which may be end()).
See Also▲
See also insert()
QLinkedList::iterator QLinkedList::erase(QLinkedList::iterator begin, QLinkedList::iterator end)▲
This is an overloaded function.
Removes all the items from begin up to (but not including) end.
T &QLinkedList::first()▲
Returns a reference to the first item in the list. This function assumes that the list isn't empty.
See Also▲
See also https://(), https://()
const T &QLinkedList::first() const▲
This is an overloaded function.
[static, since 4.1] QLinkedList<T> QLinkedList::fromStdList(const std::list<T> &list)▲
Returns a https:// object with the data contained in list. The order of the elements in the https:// is the same as in list.
Example:
std::list<double> stdlist;
list.push_back(1.2);
list.push_back(0.5);
list.push_back(3.14);
QLinkedList<double> list = QLinkedList<double>::fromStdList(stdlist);This function was introduced in Qt 4.1.
See Also▲
See also https://()
T &QLinkedList::front()▲
This function is provided for STL compatibility. It is equivalent to https://().
const T &QLinkedList::front() const▲
This is an overloaded function.
bool QLinkedList::isEmpty() const▲
T &QLinkedList::last()▲
Returns a reference to the last item in the list. This function assumes that the list isn't empty.
See Also▲
See also https://(), https://()
const T &QLinkedList::last() const▲
This is an overloaded function.
void QLinkedList::pop_back()▲
This function is provided for STL compatibility. It is equivalent to https://().
void QLinkedList::pop_front()▲
This function is provided for STL compatibility. It is equivalent to https://().
void QLinkedList::prepend(const T &value)▲
Inserts value at the beginning of the list.
Example:
QLinkedList<QString> list;
list.prepend("one");
list.prepend("two");
list.prepend("three");
// list: ["three", "two", "one"]This is the same as list.insert(https://(), value).
See Also▲
See also https://(), insert()
void QLinkedList::push_back(const T &value)▲
This function is provided for STL compatibility. It is equivalent to append(value).
void QLinkedList::push_front(const T &value)▲
This function is provided for STL compatibility. It is equivalent to prepend(value).
int QLinkedList::removeAll(const T &value)▲
Removes all occurrences of value in the list.
Example:
QList<QString> list;
list << "sun" << "cloud" << "sun" << "rain";
list.removeAll("sun");
// list: ["cloud", "rain"]This function requires the value type to have an implementation of operator==().
See Also▲
See also insert()
void QLinkedList::removeFirst()▲
Removes the first item in the list.
This is the same as erase(https://()).
See Also▲
See also https://(), https://()
void QLinkedList::removeLast()▲
[since 4.4] bool QLinkedList::removeOne(const T &value)▲
Removes the first occurrences of value in the list. Returns true on success; otherwise returns false.
Example:
QList<QString> list;
list << "sun" << "cloud" << "sun" << "rain";
list.removeOne("sun");
// list: ["cloud", "sun", "rain"]This function requires the value type to have an implementation of operator==().
This function was introduced in Qt 4.4.
See Also▲
See also insert()
int QLinkedList::size() const▲
[since 4.5] bool QLinkedList::startsWith(const T &value) const▲
Returns true if the list is not empty and its first item is equal to value; otherwise returns false.
This function was introduced in Qt 4.5.
See Also▲
See also https://(), https://()
T QLinkedList::takeFirst()▲
Removes the first item in the list and returns it.
If you don't use the return value, https://() is more efficient.
See Also▲
See also https://(), https://()
T QLinkedList::takeLast()▲
Removes the last item in the list and returns it.
If you don't use the return value, https://() is more efficient.
See Also▲
See also https://(), https://()
[since 4.1] std::list<T> QLinkedList::toStdList() const▲
Returns a std::list object with the data contained in this https://. Example:
QLinkedList<double> list;
list << 1.2 << 0.5 << 3.14;
std::list<double> stdlist = list.toStdList();This function was introduced in Qt 4.1.
See Also▲
See also https://()
bool QLinkedList::operator!=(const QLinkedList<T> &other) const▲
Returns true if 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 operator==().
See Also▲
See also operator==()
QLinkedList<T> QLinkedList::operator+(const QLinkedList<T> &other) const▲
Returns a list that contains all the items in this list followed by all the items in the other list.
See Also▲
See also https://()
QLinkedList<T> &QLinkedList::operator+=(const QLinkedList<T> &other)▲
Appends the items of the other list to this list and returns a reference to this list.
See Also▲
See also https://(), https://()
QLinkedList<T> &QLinkedList::operator+=(const T &value)▲
This is an overloaded function.
Appends value to the list.
QLinkedList<T> &QLinkedList::operator<<(const QLinkedList<T> &other)▲
Appends the items of the other list to this list and returns a reference to this list.
See Also▲
See also https://(), https://()
QLinkedList<T> &QLinkedList::operator<<(const T &value)▲
This is an overloaded function.
Appends value to the list.
QLinkedList<T> &QLinkedList::operator=(const QLinkedList<T> &other)▲
Assigns other to this list and returns a reference to this list.
[default, since 5.2] QLinkedList<T> &QLinkedList::operator=(QLinkedList<T> &&other)▲
Move-assigns other to this https:// instance.
This function was introduced in Qt 5.2.
Related Non-Members▲
QDataStream &operator<<(QDataStream &out, const QLinkedList<T> &list)▲
Writes the linked list list to stream out.
This function requires the value type to implement operator<<().
See Also▲
See also https://
QDataStream &operator>>(QDataStream &in, QLinkedList<T> &list)▲
Reads a linked list from stream in into list.
This function requires the value type to implement operator>>().
See Also▲
See also https://


