<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qlinkedlist.cpp --> <title>QLinkedList Class | Qt Core 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QLinkedList</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#related-non-members">Related Non-Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QLinkedList Class</h1> <!-- $$$QLinkedList-brief --> <p>The <a href="qlinkedlist.html">QLinkedList</a> class is a template class that provides linked lists. <a href="#details">More...</a></p> <!-- @@@QLinkedList --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QLinkedList></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul> <li><a href="qlinkedlist-members.html">List of all members, including inherited members</a></li> </ul> <p><b>Note:</b> All functions in this class are reentrant.</p> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist-const-iterator.html">const_iterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist-iterator.html">iterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#ConstIterator-typedef">ConstIterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#Iterator-typedef">Iterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#const_pointer-typedef">const_pointer</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#const_reference-typedef">const_reference</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#const_reverse_iterator-typedef">const_reverse_iterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#difference_type-typedef">difference_type</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#pointer-typedef">pointer</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#reference-typedef">reference</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#reverse_iterator-typedef">reverse_iterator</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#size_type-typedef">size_type</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#value_type-typedef">value_type</a></b></td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#QLinkedList-1">QLinkedList</a></b>(const QLinkedList<T> &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#QLinkedList-2">QLinkedList</a></b>(std::initializer_list<T> <i>list</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#QLinkedList-3">QLinkedList</a></b>(QLinkedList<T> &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#dtor.QLinkedList">~QLinkedList</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#append">append</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#back">back</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#back-1">back</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#begin">begin</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#begin-1">begin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#cbegin">cbegin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#cend">cend</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#clear">clear</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#constBegin">constBegin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#constEnd">constEnd</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#contains">contains</a></b>(const T &<i>value</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#count">count</a></b>(const T &<i>value</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#count-1">count</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#crbegin">crbegin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#crend">crend</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#empty">empty</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#end">end</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#end-1">end</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#endsWith">endsWith</a></b>(const T &<i>value</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#erase">erase</a></b>(iterator <i>pos</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#erase-1">erase</a></b>(iterator <i>begin</i>, iterator <i>end</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#first">first</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#first-1">first</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#front">front</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#front-1">front</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#insert">insert</a></b>(iterator <i>before</i>, const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#isEmpty">isEmpty</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#last">last</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const T &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#last-1">last</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#pop_back">pop_back</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#pop_front">pop_front</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#prepend">prepend</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#push_back">push_back</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#push_front">push_front</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#rbegin">rbegin</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#rbegin-1">rbegin</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#removeAll">removeAll</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#removeFirst">removeFirst</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#removeLast">removeLast</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#removeOne">removeOne</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#rend">rend</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const_reverse_iterator </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#rend-1">rend</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#size">size</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#startsWith">startsWith</a></b>(const T &<i>value</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#swap">swap</a></b>(QLinkedList<T> &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#takeFirst">takeFirst</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#takeLast">takeLast</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> std::list<T> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#toStdList">toStdList</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-not-eq">operator!=</a></b>(const QLinkedList<T> &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-2b">operator+</a></b>(const QLinkedList<T> &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-2b-eq">operator+=</a></b>(const QLinkedList<T> &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-2b-eq-1">operator+=</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-lt-lt">operator<<</a></b>(const QLinkedList<T> &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-lt-lt-1">operator<<</a></b>(const T &<i>value</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-eq">operator=</a></b>(const QLinkedList<T> &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-eq-1">operator=</a></b>(QLinkedList<T> &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-eq-eq">operator==</a></b>(const QLinkedList<T> &<i>other</i>) const</td></tr> </table></div> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QLinkedList<T> </td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#fromStdList">fromStdList</a></b>(const std::list<T> &<i>list</i>)</td></tr> </table></div> <a name="related-non-members"></a> <h2 id="related-non-members">Related Non-Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-lt-lt-2">operator<<</a></b>(QDataStream &<i>out</i>, const QLinkedList<T> &<i>list</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qlinkedlist.html#operator-gt-gt">operator>></a></b>(QDataStream &<i>in</i>, QLinkedList<T> &<i>list</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QLinkedList-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qlinkedlist.html">QLinkedList</a> class is a template class that provides linked lists.</p> <p><a href="qlinkedlist.html">QLinkedList</a><T> is one of Qt's generic <a href="containers.html">container classes</a>. It stores a list of values and provides iterator-based access as well as <a href="containers.html#constant-time">constant time</a> insertions and removals.</p> <p><a href="qlist.html">QList</a><T>, <a href="qlinkedlist.html">QLinkedList</a><T>, and <a href="qvector.html">QVector</a><T> provide similar functionality. Here's an overview:</p> <ul> <li>For most purposes, <a href="qlist.html">QList</a> is the right class to use. Its index-based API is more convenient than <a href="qlinkedlist.html">QLinkedList</a>'s iterator-based API, and it is usually faster than <a href="qvector.html">QVector</a> because of the way it stores its items in memory (see <a href="containers.html#algorithmic-complexity">Algorithmic Complexity</a> for details). It also expands to less code in your executable.</li> <li>If you need a real linked list, with guarantees of <a href="containers.html#constant-time">constant time</a> insertions in the middle of the list and iterators to items rather than indexes, use <a href="qlinkedlist.html">QLinkedList</a>.</li> <li>If you want the items to occupy adjacent memory positions, use <a href="qvector.html">QVector</a>.</li> </ul> <p>Here's an example of a <a href="qlinkedlist.html">QLinkedList</a> that stores integers and a <a href="qlinkedlist.html">QLinkedList</a> that stores <a href="qtime.html">QTime</a> values:</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type">int</span><span class="operator">></span> integerList; <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type"><a href="qtime.html">QTime</a></span><span class="operator">></span> timeList; </pre> <p><a href="qlinkedlist.html">QLinkedList</a> stores a list of items. The default constructor creates an empty list. To insert items into the list, you can use operator<<():</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">></span> list; list <span class="operator"><</span><span class="operator"><</span> <span class="string">"one"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"two"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"three"</span>; <span class="comment">// list: ["one", "two", "three"]</span> </pre> <p>If you want to get the first or last item in a linked list, use <a href="qlinkedlist.html#first">first</a>() or <a href="qlinkedlist.html#last">last</a>(). If you want to remove an item from either end of the list, use <a href="qlinkedlist.html#removeFirst">removeFirst</a>() or <a href="qlinkedlist.html#removeLast">removeLast</a>(). If you want to remove all occurrences of a given value in the list, use <a href="qlinkedlist.html#removeAll">removeAll</a>().</p> <p>A common requirement is to remove the first or last item in the list and do something with it. For this, <a href="qlinkedlist.html">QLinkedList</a> provides <a href="qlinkedlist.html#takeFirst">takeFirst</a>() and <a href="qlinkedlist.html#takeLast">takeLast</a>(). Here's a loop that removes the items from a list one at a time and calls <code>delete</code> on them:</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span><span class="operator">></span> list; <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> <span class="keyword">while</span> (<span class="operator">!</span>list<span class="operator">.</span>isEmpty()) <span class="keyword">delete</span> list<span class="operator">.</span>takeFirst(); </pre> <p><a href="qlinkedlist.html">QLinkedList</a>'s value type must be an <a href="containers.html#assignable-data-type">assignable data type</a>. This covers most data types that are commonly used, but the compiler won't let you, for example, store a <a href="../qtwidgets/qwidget.html">QWidget</a> as a value; instead, store a <a href="../qtwidgets/qwidget.html">QWidget</a> *. A few functions have additional requirements; for example, <a href="qlinkedlist.html#contains">contains</a>() and <a href="qlinkedlist.html#removeAll">removeAll</a>() expect the value type to support <code>operator==()</code>. These requirements are documented on a per-function basis.</p> <p>If you want to insert, modify, or remove items in the middle of the list, you must use an iterator. <a href="qlinkedlist.html">QLinkedList</a> provides both <a href="containers.html#java-style-iterators">Java-style iterators</a> (<a href="qlinkedlistiterator.html">QLinkedListIterator</a> and <a href="qmutablelinkedlistiterator.html">QMutableLinkedListIterator</a>) and <a href="containers.html#stl-style-iterators">STL-style iterators</a> (<a href="qlinkedlist-const-iterator.html">QLinkedList::const_iterator</a> and <a href="qlinkedlist-iterator.html">QLinkedList::iterator</a>). See the documentation for these classes for details.</p> </div> <p><b>See also </b><a href="qlinkedlistiterator.html">QLinkedListIterator</a>, <a href="qmutablelinkedlistiterator.html">QMutableLinkedListIterator</a>, <a href="qlist.html">QList</a>, and <a href="qvector.html">QVector</a>.</p> <!-- @@@QLinkedList --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$ConstIterator --> <h3 class="fn" id="ConstIterator-typedef"><a name="ConstIterator-typedef"></a>typedef QLinkedList::<span class="name">ConstIterator</span></h3> <p>Qt-style synonym for <a href="qlinkedlist-const-iterator.html">QLinkedList::const_iterator</a>.</p> <!-- @@@ConstIterator --> <!-- $$$Iterator --> <h3 class="fn" id="Iterator-typedef"><a name="Iterator-typedef"></a>typedef QLinkedList::<span class="name">Iterator</span></h3> <p>Qt-style synonym for <a href="qlinkedlist-iterator.html">QLinkedList::iterator</a>.</p> <!-- @@@Iterator --> <!-- $$$const_pointer --> <h3 class="fn" id="const_pointer-typedef"><a name="const_pointer-typedef"></a>typedef QLinkedList::<span class="name">const_pointer</span></h3> <p>Typedef for const T *. Provided for STL compatibility.</p> <!-- @@@const_pointer --> <!-- $$$const_reference --> <h3 class="fn" id="const_reference-typedef"><a name="const_reference-typedef"></a>typedef QLinkedList::<span class="name">const_reference</span></h3> <p>Typedef for const T &. Provided for STL compatibility.</p> <!-- @@@const_reference --> <!-- $$$const_reverse_iterator --> <h3 class="fn" id="const_reverse_iterator-typedef"><a name="const_reverse_iterator-typedef"></a>typedef QLinkedList::<span class="name">const_reverse_iterator</span></h3> <p>The QLinkedList::const_reverse_iterator typedef provides an STL-style const reverse iterator for <a href="qlinkedlist.html">QLinkedList</a>.</p> <p>It is simply a typedef for <code>std::reverse_iterator<QLinkedList::const_iterator></code>.</p> <p><b>Warning:</b> 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 <a href="containers.html#implicit-sharing-iterator-problem">Implicit sharing iterator problem</a>.</p> <p>This typedef was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#rbegin">QLinkedList::rbegin</a>(), <a href="qlinkedlist.html#rend">QLinkedList::rend</a>(), <a href="qlinkedlist.html#reverse_iterator-typedef">QLinkedList::reverse_iterator</a>, and <a href="qlinkedlist-const-iterator.html">QLinkedList::const_iterator</a>.</p> <!-- @@@const_reverse_iterator --> <!-- $$$difference_type --> <h3 class="fn" id="difference_type-typedef"><a name="difference_type-typedef"></a>typedef QLinkedList::<span class="name">difference_type</span></h3> <p>Typedef for ptrdiff_t. Provided for STL compatibility.</p> <!-- @@@difference_type --> <!-- $$$pointer --> <h3 class="fn" id="pointer-typedef"><a name="pointer-typedef"></a>typedef QLinkedList::<span class="name">pointer</span></h3> <p>Typedef for T *. Provided for STL compatibility.</p> <!-- @@@pointer --> <!-- $$$reference --> <h3 class="fn" id="reference-typedef"><a name="reference-typedef"></a>typedef QLinkedList::<span class="name">reference</span></h3> <p>Typedef for T &. Provided for STL compatibility.</p> <!-- @@@reference --> <!-- $$$reverse_iterator --> <h3 class="fn" id="reverse_iterator-typedef"><a name="reverse_iterator-typedef"></a>typedef QLinkedList::<span class="name">reverse_iterator</span></h3> <p>The QLinkedList::reverse_iterator typedef provides an STL-style non-const reverse iterator for <a href="qlinkedlist.html">QLinkedList</a>.</p> <p>It is simply a typedef for <code>std::reverse_iterator<QLinkedList::iterator></code>.</p> <p><b>Warning:</b> 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 <a href="containers.html#implicit-sharing-iterator-problem">Implicit sharing iterator problem</a>.</p> <p>This typedef was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#rbegin">QLinkedList::rbegin</a>(), <a href="qlinkedlist.html#rend">QLinkedList::rend</a>(), <a href="qlinkedlist.html#const_reverse_iterator-typedef">QLinkedList::const_reverse_iterator</a>, and <a href="qlinkedlist-iterator.html">QLinkedList::iterator</a>.</p> <!-- @@@reverse_iterator --> <!-- $$$size_type --> <h3 class="fn" id="size_type-typedef"><a name="size_type-typedef"></a>typedef QLinkedList::<span class="name">size_type</span></h3> <p>Typedef for int. Provided for STL compatibility.</p> <!-- @@@size_type --> <!-- $$$value_type --> <h3 class="fn" id="value_type-typedef"><a name="value_type-typedef"></a>typedef QLinkedList::<span class="name">value_type</span></h3> <p>Typedef for T. Provided for STL compatibility.</p> <!-- @@@value_type --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QLinkedList[overload1]$$$QLinkedList --> <h3 class="fn" id="QLinkedList"><a name="QLinkedList"></a>QLinkedList::<span class="name">QLinkedList</span>()</h3> <p>Constructs an empty list.</p> <!-- @@@QLinkedList --> <!-- $$$QLinkedList$$$QLinkedListconstQLinkedList<T>& --> <h3 class="fn" id="QLinkedList-1"><a name="QLinkedList-1"></a>QLinkedList::<span class="name">QLinkedList</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>)</h3> <p>Constructs a copy of <i>other</i>.</p> <p>This operation occurs in <a href="containers.html#constant-time">constant time</a>, because <a href="qlinkedlist.html">QLinkedList</a> is <a href="implicit-sharing.html">implicitly shared</a>. This makes returning a <a href="qlinkedlist.html">QLinkedList</a> from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes <a href="containers.html#linear-time">linear time</a>.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-eq">operator=</a>().</p> <!-- @@@QLinkedList --> <!-- $$$QLinkedList$$$QLinkedListstd::initializer_list<T> --> <h3 class="fn" id="QLinkedList-2"><a name="QLinkedList-2"></a>QLinkedList::<span class="name">QLinkedList</span>(<span class="type">std::initializer_list</span><<span class="type">T</span>> <i>list</i>)</h3> <p>Constructs a list from the std::initializer_list specified by <i>list</i>.</p> <p>This constructor is only enabled if the compiler supports C++11 initializer lists.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@QLinkedList --> <!-- $$$QLinkedList$$$QLinkedListQLinkedList<T>&& --> <h3 class="fn" id="QLinkedList-3"><a name="QLinkedList-3"></a>QLinkedList::<span class="name">QLinkedList</span>(<span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &&<i>other</i>)</h3> <p>Move-constructs a <a href="qlinkedlist.html">QLinkedList</a> instance, making it point at the same object that <i>other</i> was pointing to.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@QLinkedList --> <!-- $$$~QLinkedList[overload1]$$$~QLinkedList --> <h3 class="fn" id="dtor.QLinkedList"><a name="dtor.QLinkedList"></a>QLinkedList::<span class="name">~QLinkedList</span>()</h3> <p>Destroys the list. References to the values in the list, and all iterators over this list, become invalid.</p> <!-- @@@~QLinkedList --> <!-- $$$append[overload1]$$$appendconstT& --> <h3 class="fn" id="append"><a name="append"></a><span class="type">void</span> QLinkedList::<span class="name">append</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>Inserts <i>value</i> at the end of the list.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">></span> list; list<span class="operator">.</span>append(<span class="string">"one"</span>); list<span class="operator">.</span>append(<span class="string">"two"</span>); list<span class="operator">.</span>append(<span class="string">"three"</span>); <span class="comment">// list: ["one", "two", "three"]</span> </pre> <p>This is the same as list.insert(<a href="qlinkedlist.html#end">end</a>(), <i>value</i>).</p> <p><b>See also </b><a href="qlinkedlist.html#operator-lt-lt">operator<<</a>(), <a href="qlinkedlist.html#prepend">prepend</a>(), and <a href="qlinkedlist.html#insert">insert</a>().</p> <!-- @@@append --> <!-- $$$back[overload1]$$$back --> <h3 class="fn" id="back"><a name="back"></a><span class="type">T</span> &QLinkedList::<span class="name">back</span>()</h3> <p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#last">last</a>().</p> <!-- @@@back --> <!-- $$$back$$$back --> <h3 class="fn" id="back-1"><a name="back-1"></a>const <span class="type">T</span> &QLinkedList::<span class="name">back</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@back --> <!-- $$$begin[overload1]$$$begin --> <h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> QLinkedList::<span class="name">begin</span>()</h3> <p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#constBegin">constBegin</a>() and <a href="qlinkedlist.html#end">end</a>().</p> <!-- @@@begin --> <!-- $$$begin$$$begin --> <h3 class="fn" id="begin-1"><a name="begin-1"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">begin</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@begin --> <!-- $$$cbegin[overload1]$$$cbegin --> <h3 class="fn" id="cbegin"><a name="cbegin"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">cbegin</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the list.</p> <p>This function was introduced in Qt 5.0.</p> <p><b>See also </b><a href="qlinkedlist.html#begin">begin</a>() and <a href="qlinkedlist.html#cend">cend</a>().</p> <!-- @@@cbegin --> <!-- $$$cend[overload1]$$$cend --> <h3 class="fn" id="cend"><a name="cend"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">cend</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the list.</p> <p>This function was introduced in Qt 5.0.</p> <p><b>See also </b><a href="qlinkedlist.html#cbegin">cbegin</a>() and <a href="qlinkedlist.html#end">end</a>().</p> <!-- @@@cend --> <!-- $$$clear[overload1]$$$clear --> <h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QLinkedList::<span class="name">clear</span>()</h3> <p>Removes all the items in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#removeAll">removeAll</a>().</p> <!-- @@@clear --> <!-- $$$constBegin[overload1]$$$constBegin --> <h3 class="fn" id="constBegin"><a name="constBegin"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">constBegin</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#begin">begin</a>() and <a href="qlinkedlist.html#constEnd">constEnd</a>().</p> <!-- @@@constBegin --> <!-- $$$constEnd[overload1]$$$constEnd --> <h3 class="fn" id="constEnd"><a name="constEnd"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">constEnd</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#constBegin">constBegin</a>() and <a href="qlinkedlist.html#end">end</a>().</p> <!-- @@@constEnd --> <!-- $$$contains[overload1]$$$containsconstT& --> <h3 class="fn" id="contains"><a name="contains"></a><span class="type">bool</span> QLinkedList::<span class="name">contains</span>(const <span class="type">T</span> &<i>value</i>) const</h3> <p>Returns <code>true</code> if the list contains an occurrence of <i>value</i>; otherwise returns <code>false</code>.</p> <p>This function requires the value type to have an implementation of <code>operator==()</code>.</p> <p><b>See also </b><a href="qlinkedlistiterator.html#findNext">QLinkedListIterator::findNext</a>() and <a href="qlinkedlistiterator.html#findPrevious">QLinkedListIterator::findPrevious</a>().</p> <!-- @@@contains --> <!-- $$$count[overload1]$$$countconstT& --> <h3 class="fn" id="count"><a name="count"></a><span class="type">int</span> QLinkedList::<span class="name">count</span>(const <span class="type">T</span> &<i>value</i>) const</h3> <p>Returns the number of occurrences of <i>value</i> in the list.</p> <p>This function requires the value type to have an implementation of <code>operator==()</code>.</p> <p><b>See also </b><a href="qlinkedlist.html#contains">contains</a>().</p> <!-- @@@count --> <!-- $$$count$$$count --> <h3 class="fn" id="count-1"><a name="count-1"></a><span class="type">int</span> QLinkedList::<span class="name">count</span>() const</h3> <p>Same as <a href="qlinkedlist.html#size">size</a>().</p> <!-- @@@count --> <!-- $$$crbegin[overload1]$$$crbegin --> <h3 class="fn" id="crbegin"><a name="crbegin"></a><span class="type"><a href="qlinkedlist.html#const_reverse_iterator-typedef">const_reverse_iterator</a></span> QLinkedList::<span class="name">crbegin</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style</a> reverse iterator pointing to the first item in the list, in reverse order.</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#begin">begin</a>(), <a href="qlinkedlist.html#rbegin">rbegin</a>(), and <a href="qlinkedlist.html#rend">rend</a>().</p> <!-- @@@crbegin --> <!-- $$$crend[overload1]$$$crend --> <h3 class="fn" id="crend"><a name="crend"></a><span class="type"><a href="qlinkedlist.html#const_reverse_iterator-typedef">const_reverse_iterator</a></span> QLinkedList::<span class="name">crend</span>() const</h3> <p>Returns a const <a href="containers.html#stl-style-iterators">STL-style</a> reverse iterator pointing to one past the last item in the list, in reverse order.</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#end">end</a>(), <a href="qlinkedlist.html#rend">rend</a>(), and <a href="qlinkedlist.html#rbegin">rbegin</a>().</p> <!-- @@@crend --> <!-- $$$empty[overload1]$$$empty --> <h3 class="fn" id="empty"><a name="empty"></a><span class="type">bool</span> QLinkedList::<span class="name">empty</span>() const</h3> <p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#isEmpty">isEmpty</a>() and returns <code>true</code> if the list is empty.</p> <!-- @@@empty --> <!-- $$$end[overload1]$$$end --> <h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> QLinkedList::<span class="name">end</span>()</h3> <p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#begin">begin</a>() and <a href="qlinkedlist.html#constEnd">constEnd</a>().</p> <!-- @@@end --> <!-- $$$end$$$end --> <h3 class="fn" id="end-1"><a name="end-1"></a><span class="type"><a href="qlinkedlist-const-iterator.html">const_iterator</a></span> QLinkedList::<span class="name">end</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@end --> <!-- $$$endsWith[overload1]$$$endsWithconstT& --> <h3 class="fn" id="endsWith"><a name="endsWith"></a><span class="type">bool</span> QLinkedList::<span class="name">endsWith</span>(const <span class="type">T</span> &<i>value</i>) const</h3> <p>Returns <code>true</code> if the list is not empty and its last item is equal to <i>value</i>; otherwise returns <code>false</code>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also </b><a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#last">last</a>().</p> <!-- @@@endsWith --> <!-- $$$erase[overload1]$$$eraseiterator --> <h3 class="fn" id="erase"><a name="erase"></a><span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> QLinkedList::<span class="name">erase</span>(<span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> <i>pos</i>)</h3> <p>Removes the item pointed to by the iterator <i>pos</i> from the list, and returns an iterator to the next item in the list (which may be <a href="qlinkedlist.html#end">end</a>()).</p> <p><b>See also </b><a href="qlinkedlist.html#insert">insert</a>().</p> <!-- @@@erase --> <!-- $$$erase$$$eraseiteratoriterator --> <h3 class="fn" id="erase-1"><a name="erase-1"></a><span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> QLinkedList::<span class="name">erase</span>(<span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> <i>begin</i>, <span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> <i>end</i>)</h3> <p>This is an overloaded function.</p> <p>Removes all the items from <i>begin</i> up to (but not including) <i>end</i>.</p> <!-- @@@erase --> <!-- $$$first[overload1]$$$first --> <h3 class="fn" id="first"><a name="first"></a><span class="type">T</span> &QLinkedList::<span class="name">first</span>()</h3> <p>Returns a reference to the first item in the list. This function assumes that the list isn't empty.</p> <p><b>See also </b><a href="qlinkedlist.html#last">last</a>() and <a href="qlinkedlist.html#isEmpty">isEmpty</a>().</p> <!-- @@@first --> <!-- $$$first$$$first --> <h3 class="fn" id="first-1"><a name="first-1"></a>const <span class="type">T</span> &QLinkedList::<span class="name">first</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@first --> <!-- $$$fromStdList[overload1]$$$fromStdListconststd::list<T>& --> <h3 class="fn" id="fromStdList"><a name="fromStdList"></a><code>[static] </code><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> QLinkedList::<span class="name">fromStdList</span>(const <span class="type">std::list</span><<span class="type">T</span>> &<i>list</i>)</h3> <p>Returns a <a href="qlinkedlist.html">QLinkedList</a> object with the data contained in <i>list</i>. The order of the elements in the <a href="qlinkedlist.html">QLinkedList</a> is the same as in <i>list</i>.</p> <p>Example:</p> <pre class="cpp"> std<span class="operator">::</span>list<span class="operator"><</span><span class="type">double</span><span class="operator">></span> stdlist; list<span class="operator">.</span>push_back(<span class="number">1.2</span>); list<span class="operator">.</span>push_back(<span class="number">0.5</span>); list<span class="operator">.</span>push_back(<span class="number">3.14</span>); <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type">double</span><span class="operator">></span> list <span class="operator">=</span> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type">double</span><span class="operator">></span><span class="operator">::</span>fromStdList(stdlist); </pre> <p>This function was introduced in Qt 4.1.</p> <p><b>See also </b><a href="qlinkedlist.html#toStdList">toStdList</a>().</p> <!-- @@@fromStdList --> <!-- $$$front[overload1]$$$front --> <h3 class="fn" id="front"><a name="front"></a><span class="type">T</span> &QLinkedList::<span class="name">front</span>()</h3> <p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#first">first</a>().</p> <!-- @@@front --> <!-- $$$front$$$front --> <h3 class="fn" id="front-1"><a name="front-1"></a>const <span class="type">T</span> &QLinkedList::<span class="name">front</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@front --> <!-- $$$insert[overload1]$$$insertiteratorconstT& --> <h3 class="fn" id="insert"><a name="insert"></a><span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> QLinkedList::<span class="name">insert</span>(<span class="type"><a href="qlinkedlist-iterator.html">iterator</a></span> <i>before</i>, const <span class="type">T</span> &<i>value</i>)</h3> <p>Inserts <i>value</i> in front of the item pointed to by the iterator <i>before</i>. Returns an iterator pointing at the inserted item.</p> <p><b>See also </b><a href="qlinkedlist.html#erase">erase</a>().</p> <!-- @@@insert --> <!-- $$$isEmpty[overload1]$$$isEmpty --> <h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QLinkedList::<span class="name">isEmpty</span>() const</h3> <p>Returns <code>true</code> if the list contains no items; otherwise returns false.</p> <p><b>See also </b><a href="qlinkedlist.html#size">size</a>().</p> <!-- @@@isEmpty --> <!-- $$$last[overload1]$$$last --> <h3 class="fn" id="last"><a name="last"></a><span class="type">T</span> &QLinkedList::<span class="name">last</span>()</h3> <p>Returns a reference to the last item in the list. This function assumes that the list isn't empty.</p> <p><b>See also </b><a href="qlinkedlist.html#first">first</a>() and <a href="qlinkedlist.html#isEmpty">isEmpty</a>().</p> <!-- @@@last --> <!-- $$$last$$$last --> <h3 class="fn" id="last-1"><a name="last-1"></a>const <span class="type">T</span> &QLinkedList::<span class="name">last</span>() const</h3> <p>This is an overloaded function.</p> <!-- @@@last --> <!-- $$$pop_back[overload1]$$$pop_back --> <h3 class="fn" id="pop_back"><a name="pop_back"></a><span class="type">void</span> QLinkedList::<span class="name">pop_back</span>()</h3> <p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#removeLast">removeLast</a>().</p> <!-- @@@pop_back --> <!-- $$$pop_front[overload1]$$$pop_front --> <h3 class="fn" id="pop_front"><a name="pop_front"></a><span class="type">void</span> QLinkedList::<span class="name">pop_front</span>()</h3> <p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#removeFirst">removeFirst</a>().</p> <!-- @@@pop_front --> <!-- $$$prepend[overload1]$$$prependconstT& --> <h3 class="fn" id="prepend"><a name="prepend"></a><span class="type">void</span> QLinkedList::<span class="name">prepend</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>Inserts <i>value</i> at the beginning of the list.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">></span> list; list<span class="operator">.</span>prepend(<span class="string">"one"</span>); list<span class="operator">.</span>prepend(<span class="string">"two"</span>); list<span class="operator">.</span>prepend(<span class="string">"three"</span>); <span class="comment">// list: ["three", "two", "one"]</span> </pre> <p>This is the same as list.insert(<a href="qlinkedlist.html#begin">begin</a>(), <i>value</i>).</p> <p><b>See also </b><a href="qlinkedlist.html#append">append</a>() and <a href="qlinkedlist.html#insert">insert</a>().</p> <!-- @@@prepend --> <!-- $$$push_back[overload1]$$$push_backconstT& --> <h3 class="fn" id="push_back"><a name="push_back"></a><span class="type">void</span> QLinkedList::<span class="name">push_back</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>This function is provided for STL compatibility. It is equivalent to append(<i>value</i>).</p> <!-- @@@push_back --> <!-- $$$push_front[overload1]$$$push_frontconstT& --> <h3 class="fn" id="push_front"><a name="push_front"></a><span class="type">void</span> QLinkedList::<span class="name">push_front</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>This function is provided for STL compatibility. It is equivalent to prepend(<i>value</i>).</p> <!-- @@@push_front --> <!-- $$$rbegin[overload1]$$$rbegin --> <h3 class="fn" id="rbegin"><a name="rbegin"></a><span class="type"><a href="qlinkedlist.html#reverse_iterator-typedef">reverse_iterator</a></span> QLinkedList::<span class="name">rbegin</span>()</h3> <p>Returns a <a href="containers.html#stl-style-iterators">STL-style</a> reverse iterator pointing to the first item in the list, in reverse order.</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#begin">begin</a>(), <a href="qlinkedlist.html#crbegin">crbegin</a>(), and <a href="qlinkedlist.html#rend">rend</a>().</p> <!-- @@@rbegin --> <!-- $$$rbegin$$$rbegin --> <h3 class="fn" id="rbegin-1"><a name="rbegin-1"></a><span class="type"><a href="qlinkedlist.html#const_reverse_iterator-typedef">const_reverse_iterator</a></span> QLinkedList::<span class="name">rbegin</span>() const</h3> <p>This is an overloaded function.</p> <p>This function was introduced in Qt 5.6.</p> <!-- @@@rbegin --> <!-- $$$removeAll[overload1]$$$removeAllconstT& --> <h3 class="fn" id="removeAll"><a name="removeAll"></a><span class="type">int</span> QLinkedList::<span class="name">removeAll</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>Removes all occurrences of <i>value</i> in the list.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">></span> list; list <span class="operator"><</span><span class="operator"><</span> <span class="string">"sun"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"cloud"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"sun"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"rain"</span>; list<span class="operator">.</span>removeAll(<span class="string">"sun"</span>); <span class="comment">// list: ["cloud", "rain"]</span> </pre> <p>This function requires the value type to have an implementation of <code>operator==()</code>.</p> <p><b>See also </b><a href="qlinkedlist.html#insert">insert</a>().</p> <!-- @@@removeAll --> <!-- $$$removeFirst[overload1]$$$removeFirst --> <h3 class="fn" id="removeFirst"><a name="removeFirst"></a><span class="type">void</span> QLinkedList::<span class="name">removeFirst</span>()</h3> <p>Removes the first item in the list.</p> <p>This is the same as erase(<a href="qlinkedlist.html#begin">begin</a>()).</p> <p><b>See also </b><a href="qlinkedlist.html#removeLast">removeLast</a>() and <a href="qlinkedlist.html#erase">erase</a>().</p> <!-- @@@removeFirst --> <!-- $$$removeLast[overload1]$$$removeLast --> <h3 class="fn" id="removeLast"><a name="removeLast"></a><span class="type">void</span> QLinkedList::<span class="name">removeLast</span>()</h3> <p>Removes the last item in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#removeFirst">removeFirst</a>() and <a href="qlinkedlist.html#erase">erase</a>().</p> <!-- @@@removeLast --> <!-- $$$removeOne[overload1]$$$removeOneconstT& --> <h3 class="fn" id="removeOne"><a name="removeOne"></a><span class="type">bool</span> QLinkedList::<span class="name">removeOne</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>Removes the first occurrences of <i>value</i> in the list. Returns <code>true</code> on success; otherwise returns <code>false</code>.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">></span> list; list <span class="operator"><</span><span class="operator"><</span> <span class="string">"sun"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"cloud"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"sun"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"rain"</span>; list<span class="operator">.</span>removeOne(<span class="string">"sun"</span>); <span class="comment">// list: ["cloud", "sun", "rain"]</span> </pre> <p>This function requires the value type to have an implementation of <code>operator==()</code>.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also </b><a href="qlinkedlist.html#insert">insert</a>().</p> <!-- @@@removeOne --> <!-- $$$rend[overload1]$$$rend --> <h3 class="fn" id="rend"><a name="rend"></a><span class="type"><a href="qlinkedlist.html#reverse_iterator-typedef">reverse_iterator</a></span> QLinkedList::<span class="name">rend</span>()</h3> <p>Returns a <a href="containers.html#stl-style-iterators">STL-style</a> reverse iterator pointing to one past the last item in the list, in reverse order.</p> <p>This function was introduced in Qt 5.6.</p> <p><b>See also </b><a href="qlinkedlist.html#end">end</a>(), <a href="qlinkedlist.html#crend">crend</a>(), and <a href="qlinkedlist.html#rbegin">rbegin</a>().</p> <!-- @@@rend --> <!-- $$$rend$$$rend --> <h3 class="fn" id="rend-1"><a name="rend-1"></a><span class="type"><a href="qlinkedlist.html#const_reverse_iterator-typedef">const_reverse_iterator</a></span> QLinkedList::<span class="name">rend</span>() const</h3> <p>This is an overloaded function.</p> <p>This function was introduced in Qt 5.6.</p> <!-- @@@rend --> <!-- $$$size[overload1]$$$size --> <h3 class="fn" id="size"><a name="size"></a><span class="type">int</span> QLinkedList::<span class="name">size</span>() const</h3> <p>Returns the number of items in the list.</p> <p><b>See also </b><a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#count-1">count</a>().</p> <!-- @@@size --> <!-- $$$startsWith[overload1]$$$startsWithconstT& --> <h3 class="fn" id="startsWith"><a name="startsWith"></a><span class="type">bool</span> QLinkedList::<span class="name">startsWith</span>(const <span class="type">T</span> &<i>value</i>) const</h3> <p>Returns <code>true</code> if the list is not empty and its first item is equal to <i>value</i>; otherwise returns <code>false</code>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also </b><a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#first">first</a>().</p> <!-- @@@startsWith --> <!-- $$$swap[overload1]$$$swapQLinkedList<T>& --> <h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QLinkedList::<span class="name">swap</span>(<span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>)</h3> <p>Swaps list <i>other</i> with this list. This operation is very fast and never fails.</p> <p>This function was introduced in Qt 4.8.</p> <!-- @@@swap --> <!-- $$$takeFirst[overload1]$$$takeFirst --> <h3 class="fn" id="takeFirst"><a name="takeFirst"></a><span class="type">T</span> QLinkedList::<span class="name">takeFirst</span>()</h3> <p>Removes the first item in the list and returns it.</p> <p>If you don't use the return value, <a href="qlinkedlist.html#removeFirst">removeFirst</a>() is more efficient.</p> <p><b>See also </b><a href="qlinkedlist.html#takeLast">takeLast</a>() and <a href="qlinkedlist.html#removeFirst">removeFirst</a>().</p> <!-- @@@takeFirst --> <!-- $$$takeLast[overload1]$$$takeLast --> <h3 class="fn" id="takeLast"><a name="takeLast"></a><span class="type">T</span> QLinkedList::<span class="name">takeLast</span>()</h3> <p>Removes the last item in the list and returns it.</p> <p>If you don't use the return value, <a href="qlinkedlist.html#removeLast">removeLast</a>() is more efficient.</p> <p><b>See also </b><a href="qlinkedlist.html#takeFirst">takeFirst</a>() and <a href="qlinkedlist.html#removeLast">removeLast</a>().</p> <!-- @@@takeLast --> <!-- $$$toStdList[overload1]$$$toStdList --> <h3 class="fn" id="toStdList"><a name="toStdList"></a><span class="type">std::list</span><<span class="type">T</span>> QLinkedList::<span class="name">toStdList</span>() const</h3> <p>Returns a std::list object with the data contained in this <a href="qlinkedlist.html">QLinkedList</a>. Example:</p> <pre class="cpp"> <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><span class="operator"><</span><span class="type">double</span><span class="operator">></span> list; list <span class="operator"><</span><span class="operator"><</span> <span class="number">1.2</span> <span class="operator"><</span><span class="operator"><</span> <span class="number">0.5</span> <span class="operator"><</span><span class="operator"><</span> <span class="number">3.14</span>; std<span class="operator">::</span>list<span class="operator"><</span><span class="type">double</span><span class="operator">></span> stdlist <span class="operator">=</span> list<span class="operator">.</span>toStdList(); </pre> <p>This function was introduced in Qt 4.1.</p> <p><b>See also </b><a href="qlinkedlist.html#fromStdList">fromStdList</a>().</p> <!-- @@@toStdList --> <!-- $$$operator!=[overload1]$$$operator!=constQLinkedList<T>& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QLinkedList::<span class="name">operator!=</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>) const</h3> <p>Returns <code>true</code> if <i>other</i> is not equal to this list; otherwise returns <code>false</code>.</p> <p>Two lists are considered equal if they contain the same values in the same order.</p> <p>This function requires the value type to implement <code>operator==()</code>.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-eq-eq">operator==</a>().</p> <!-- @@@operator!= --> <!-- $$$operator+[overload1]$$$operator+constQLinkedList<T>& --> <h3 class="fn" id="operator-2b"><a name="operator-2b"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> QLinkedList::<span class="name">operator+</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>) const</h3> <p>Returns a list that contains all the items in this list followed by all the items in the <i>other</i> list.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-2b-eq">operator+=</a>().</p> <!-- @@@operator+ --> <!-- $$$operator+=[overload1]$$$operator+=constQLinkedList<T>& --> <h3 class="fn" id="operator-2b-eq"><a name="operator-2b-eq"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator+=</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>)</h3> <p>Appends the items of the <i>other</i> list to this list and returns a reference to this list.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-2b">operator+</a>() and <a href="qlinkedlist.html#append">append</a>().</p> <!-- @@@operator+= --> <!-- $$$operator+=$$$operator+=constT& --> <h3 class="fn" id="operator-2b-eq-1"><a name="operator-2b-eq-1"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator+=</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>This is an overloaded function.</p> <p>Appends <i>value</i> to the list.</p> <!-- @@@operator+= --> <!-- $$$operator<<[overload1]$$$operator<<constQLinkedList<T>& --> <h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator<<</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>)</h3> <p>Appends the items of the <i>other</i> list to this list and returns a reference to this list.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-2b-eq">operator+=</a>() and <a href="qlinkedlist.html#append">append</a>().</p> <!-- @@@operator<< --> <!-- $$$operator<<$$$operator<<constT& --> <h3 class="fn" id="operator-lt-lt-1"><a name="operator-lt-lt-1"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator<<</span>(const <span class="type">T</span> &<i>value</i>)</h3> <p>This is an overloaded function.</p> <p>Appends <i>value</i> to the list.</p> <!-- @@@operator<< --> <!-- $$$operator=[overload1]$$$operator=constQLinkedList<T>& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator=</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>)</h3> <p>Assigns <i>other</i> to this list and returns a reference to this list.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=QLinkedList<T>&& --> <h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &QLinkedList::<span class="name">operator=</span>(<span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &&<i>other</i>)</h3> <p>Move-assigns <i>other</i> to this <a href="qlinkedlist.html">QLinkedList</a> instance.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQLinkedList<T>& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QLinkedList::<span class="name">operator==</span>(const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>other</i>) const</h3> <p>Returns <code>true</code> if <i>other</i> is equal to this list; otherwise returns false.</p> <p>Two lists are considered equal if they contain the same values in the same order.</p> <p>This function requires the value type to implement <code>operator==()</code>.</p> <p><b>See also </b><a href="qlinkedlist.html#operator-not-eq">operator!=</a>().</p> <!-- @@@operator== --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$operator<<$$$operator<<QDataStream&constQLinkedList<T>& --> <h3 class="fn" id="operator-lt-lt-2"><a name="operator-lt-lt-2"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &<span class="name">operator<<</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &<i>out</i>, const <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>list</i>)</h3> <p>Writes the linked list <i>list</i> to stream <i>out</i>.</p> <p>This function requires the value type to implement <code>operator<<()</code>.</p> <p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p> <!-- @@@operator<< --> <!-- $$$operator>>[overload1]$$$operator>>QDataStream&QLinkedList<T>& --> <h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &<span class="name">operator>></span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &<i>in</i>, <span class="type"><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></span><<span class="type">T</span>> &<i>list</i>)</h3> <p>Reads a linked list from stream <i>in</i> into <i>list</i>.</p> <p>This function requires the value type to implement <code>operator>>()</code>.</p> <p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p> <!-- @@@operator>> --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>