Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4416

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qlinkedlist.cpp -->
<head>
  <title>Qt 4.6: QLinkedList Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QLinkedList"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QLinkedList Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
</h1>
<p>The QLinkedList class is a template class that provides linked lists. <a href="#details">More...</a></p>
<pre> #include &lt;QLinkedList&gt;</pre><p>Inherited by <a href="q3valuelist.html" class="compat">Q3ValueList</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qlinkedlist-members.html">List of all members, including inherited members</a></li>
<li><a href="qlinkedlist-qt3.html">Qt 3 support members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist-const-iterator.html">const_iterator</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist-iterator.html">iterator</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#ConstIterator-typedef">ConstIterator</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#Iterator-typedef">Iterator</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#const_pointer-typedef">const_pointer</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#const_reference-typedef">const_reference</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#difference_type-typedef">difference_type</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#pointer-typedef">pointer</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#reference-typedef">reference</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#size_type-typedef">size_type</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#value_type-typedef">value_type</a></b></td></tr>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#QLinkedList">QLinkedList</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#QLinkedList-2">QLinkedList</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#dtor.QLinkedList">~QLinkedList</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#append">append</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#back">back</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#back-2">back</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#begin">begin</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const_iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#begin-2">begin</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const_iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#constBegin">constBegin</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const_iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#constEnd">constEnd</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#contains">contains</a></b> ( const T &amp; <i>value</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#count">count</a></b> ( const T &amp; <i>value</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#count-2">count</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#empty">empty</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#end">end</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const_iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#end-2">end</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#endsWith">endsWith</a></b> ( const T &amp; <i>value</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#erase">erase</a></b> ( iterator <i>pos</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#erase-2">erase</a></b> ( iterator <i>begin</i>, iterator <i>end</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#first">first</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#first-2">first</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#front">front</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#front-2">front</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">iterator </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#insert">insert</a></b> ( iterator <i>before</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#isEmpty">isEmpty</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#last">last</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#last-2">last</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#pop_back">pop_back</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#pop_front">pop_front</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#prepend">prepend</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#push_back">push_back</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#push_front">push_front</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#removeAll">removeAll</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#removeFirst">removeFirst</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#removeLast">removeLast</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#removeOne">removeOne</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#size">size</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#startsWith">startsWith</a></b> ( const T &amp; <i>value</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#takeFirst">takeFirst</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#takeLast">takeLast</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::list&lt;T&gt; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#toStdList">toStdList</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-not-eq">operator!=</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-2b">operator+</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-2b-eq">operator+=</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-2b-eq-2">operator+=</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-lt-lt">operator&lt;&lt;</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-lt-lt-2">operator&lt;&lt;</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-eq">operator=</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-eq-eq">operator==</a></b> ( const QLinkedList&lt;T&gt; &amp; <i>other</i> ) const</td></tr>
</table>
<hr />
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QLinkedList&lt;T&gt; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#fromStdList">fromStdList</a></b> ( const std::list&lt;T&gt; &amp; <i>list</i> )</td></tr>
</table>
<hr />
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-lt-lt-74">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QLinkedList&lt;T&gt; &amp; <i>list</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qlinkedlist.html#operator-gt-gt-41">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QLinkedList&lt;T&gt; &amp; <i>list</i> )</td></tr>
</table>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QLinkedList class is a template class that provides linked lists.</p>
<p>QLinkedList&lt;T&gt; is one of Qt's generic <a href="containers.html#container-classes">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>&lt;T&gt;, QLinkedList&lt;T&gt;, and <a href="qvector.html">QVector</a>&lt;T&gt; 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 QLinkedList'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 QLinkedList.</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 QLinkedList that stores integers and a QLinkedList that stores <a href="qtime.html">QTime</a> values:</p>
<pre> QLinkedList&lt;int&gt; integerList;
 QLinkedList&lt;QTime&gt; timeList;</pre>
<p>QLinkedList stores a list of items. The default constructor creates an empty list. To insert items into the list, you can use operator&lt;&lt;():</p>
<pre> QLinkedList&lt;QString&gt; list;
 list &lt;&lt; &quot;one&quot; &lt;&lt; &quot;two&quot; &lt;&lt; &quot;three&quot;;
<span class="comment"> // list: [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;]</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, QLinkedList 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 <tt>delete</tt> on them:</p>
<pre> QLinkedList&lt;QWidget *&gt; list;
 ...
 while (!list.isEmpty())
     delete list.takeFirst();</pre>
<p>QLinkedList'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="qwidget.html">QWidget</a> as a value; instead, store a <a href="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 <tt>operator==()</tt>. 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. QLinkedList 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>
<p>See also <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>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tdef/QLinkedList/ConstIterator"></a>
<h3 class="fn"><a name="ConstIterator-typedef"></a>typedef QLinkedList::ConstIterator</h3>
<p>Qt-style synonym for <a href="qlinkedlist-const-iterator.html">QLinkedList::const_iterator</a>.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/Iterator"></a>
<h3 class="fn"><a name="Iterator-typedef"></a>typedef QLinkedList::Iterator</h3>
<p>Qt-style synonym for <a href="qlinkedlist-iterator.html">QLinkedList::iterator</a>.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/const_pointer"></a>
<h3 class="fn"><a name="const_pointer-typedef"></a>typedef QLinkedList::const_pointer</h3>
<p>Typedef for const T *. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/const_reference"></a>
<h3 class="fn"><a name="const_reference-typedef"></a>typedef QLinkedList::const_reference</h3>
<p>Typedef for const T &amp;. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/difference_type"></a>
<h3 class="fn"><a name="difference_type-typedef"></a>typedef QLinkedList::difference_type</h3>
<p>Typedef for ptrdiff_t. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/pointer"></a>
<h3 class="fn"><a name="pointer-typedef"></a>typedef QLinkedList::pointer</h3>
<p>Typedef for T *. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/reference"></a>
<h3 class="fn"><a name="reference-typedef"></a>typedef QLinkedList::reference</h3>
<p>Typedef for T &amp;. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/size_type"></a>
<h3 class="fn"><a name="size_type-typedef"></a>typedef QLinkedList::size_type</h3>
<p>Typedef for int. Provided for STL compatibility.</p>
<a name="//apple_ref/cpp/tdef/QLinkedList/value_type"></a>
<h3 class="fn"><a name="value_type-typedef"></a>typedef QLinkedList::value_type</h3>
<p>Typedef for T. Provided for STL compatibility.</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QLinkedList/QLinkedList"></a>
<h3 class="fn"><a name="QLinkedList"></a>QLinkedList::QLinkedList ()</h3>
<p>Constructs an empty list.</p>
<h3 class="fn"><a name="QLinkedList-2"></a>QLinkedList::QLinkedList ( const QLinkedList&lt;T&gt; &amp; <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">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>See also <a href="qlinkedlist.html#operator-eq">operator=</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/~QLinkedList"></a>
<h3 class="fn"><a name="dtor.QLinkedList"></a>QLinkedList::~QLinkedList ()</h3>
<p>Destroys the list. References to the values in the list, and all iterators over this list, become invalid.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/append"></a>
<h3 class="fn"><a name="append"></a>void QLinkedList::append ( const T &amp; <i>value</i> )</h3>
<p>Inserts <i>value</i> at the end of the list.</p>
<p>Example:</p>
<pre> QLinkedList&lt;QString&gt; list;
 list.append(&quot;one&quot;);
 list.append(&quot;two&quot;);
 list.append(&quot;three&quot;);
<span class="comment"> // list: [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;]</span></pre>
<p>This is the same as list.insert(<a href="qlinkedlist.html#end">end</a>(), <i>value</i>).</p>
<p>See also <a href="qlinkedlist.html#operator-lt-lt">operator&lt;&lt;</a>(), <a href="qlinkedlist.html#prepend">prepend</a>(), and <a href="qlinkedlist.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/back"></a>
<h3 class="fn"><a name="back"></a>T &amp; QLinkedList::back ()</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#last">last</a>().</p>
<h3 class="fn"><a name="back-2"></a>const T &amp; QLinkedList::back () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/begin"></a>
<h3 class="fn"><a name="begin"></a><a href="qlinkedlist-iterator.html">iterator</a> QLinkedList::begin ()</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>See also <a href="qlinkedlist.html#constBegin">constBegin</a>() and <a href="qlinkedlist.html#end">end</a>().</p>
<h3 class="fn"><a name="begin-2"></a><a href="qlinkedlist-const-iterator.html">const_iterator</a> QLinkedList::begin () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/clear"></a>
<h3 class="fn"><a name="clear"></a>void QLinkedList::clear ()</h3>
<p>Removes all the items in the list.</p>
<p>See also <a href="qlinkedlist.html#removeAll">removeAll</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/constBegin"></a>
<h3 class="fn"><a name="constBegin"></a><a href="qlinkedlist-const-iterator.html">const_iterator</a> QLinkedList::constBegin () 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>See also <a href="qlinkedlist.html#begin">begin</a>() and <a href="qlinkedlist.html#constEnd">constEnd</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/constEnd"></a>
<h3 class="fn"><a name="constEnd"></a><a href="qlinkedlist-const-iterator.html">const_iterator</a> QLinkedList::constEnd () 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>See also <a href="qlinkedlist.html#constBegin">constBegin</a>() and <a href="qlinkedlist.html#end">end</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/contains"></a>
<h3 class="fn"><a name="contains"></a>bool QLinkedList::contains ( const T &amp; <i>value</i> ) const</h3>
<p>Returns true if the list contains an occurrence of <i>value</i>; otherwise returns false.</p>
<p>This function requires the value type to have an implementation of <tt>operator==()</tt>.</p>
<p>See also <a href="qlinkedlistiterator.html#findNext">QLinkedListIterator::findNext</a>() and <a href="qlinkedlistiterator.html#findPrevious">QLinkedListIterator::findPrevious</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/count"></a>
<h3 class="fn"><a name="count"></a>int QLinkedList::count ( const T &amp; <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 <tt>operator==()</tt>.</p>
<p>See also <a href="qlinkedlist.html#contains">contains</a>().</p>
<h3 class="fn"><a name="count-2"></a>int QLinkedList::count () const</h3>
<p>Same as <a href="qlinkedlist.html#size">size</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/empty"></a>
<h3 class="fn"><a name="empty"></a>bool QLinkedList::empty () const</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#isEmpty">isEmpty</a>() and returns true if the list is empty.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/end"></a>
<h3 class="fn"><a name="end"></a><a href="qlinkedlist-iterator.html">iterator</a> QLinkedList::end ()</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>See also <a href="qlinkedlist.html#begin">begin</a>() and <a href="qlinkedlist.html#constEnd">constEnd</a>().</p>
<h3 class="fn"><a name="end-2"></a><a href="qlinkedlist-const-iterator.html">const_iterator</a> QLinkedList::end () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/endsWith"></a>
<h3 class="fn"><a name="endsWith"></a>bool QLinkedList::endsWith ( const T &amp; <i>value</i> ) const</h3>
<p>Returns true if the list is not empty and its last item is equal to <i>value</i>; otherwise returns false.</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#last">last</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/erase"></a>
<h3 class="fn"><a name="erase"></a><a href="qlinkedlist-iterator.html">iterator</a> QLinkedList::erase ( <a href="qlinkedlist-iterator.html">iterator</a> <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>See also <a href="qlinkedlist.html#insert">insert</a>().</p>
<h3 class="fn"><a name="erase-2"></a><a href="qlinkedlist-iterator.html">iterator</a> QLinkedList::erase ( <a href="qlinkedlist-iterator.html">iterator</a> <i>begin</i>, <a href="qlinkedlist-iterator.html">iterator</a> <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>
<a name="//apple_ref/cpp/instm/QLinkedList/first"></a>
<h3 class="fn"><a name="first"></a>T &amp; QLinkedList::first ()</h3>
<p>Returns a reference to the first item in the list. This function assumes that the list isn't empty.</p>
<p>See also <a href="qlinkedlist.html#last">last</a>() and <a href="qlinkedlist.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="first-2"></a>const T &amp; QLinkedList::first () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/clm/QLinkedList/fromStdList"></a>
<h3 class="fn"><a name="fromStdList"></a>QLinkedList&lt;T&gt; QLinkedList::fromStdList ( const std::list&lt;T&gt; &amp; <i>list</i> )&nbsp;&nbsp;<tt> [static]</tt></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> std::list&lt;double&gt; stdlist;
 list.push_back(1.2);
 list.push_back(0.5);
 list.push_back(3.14);

 QLinkedList&lt;double&gt; list = QLinkedList&lt;double&gt;::fromStdList(stdlist);</pre>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qlinkedlist.html#toStdList">toStdList</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/front"></a>
<h3 class="fn"><a name="front"></a>T &amp; QLinkedList::front ()</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#first">first</a>().</p>
<h3 class="fn"><a name="front-2"></a>const T &amp; QLinkedList::front () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/insert"></a>
<h3 class="fn"><a name="insert"></a><a href="qlinkedlist-iterator.html">iterator</a> QLinkedList::insert ( <a href="qlinkedlist-iterator.html">iterator</a> <i>before</i>, const T &amp; <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>See also <a href="qlinkedlist.html#erase">erase</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/isEmpty"></a>
<h3 class="fn"><a name="isEmpty"></a>bool QLinkedList::isEmpty () const</h3>
<p>Returns true if the list contains no items; otherwise returns false.</p>
<p>See also <a href="qlinkedlist.html#size">size</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/last"></a>
<h3 class="fn"><a name="last"></a>T &amp; QLinkedList::last ()</h3>
<p>Returns a reference to the last item in the list. This function assumes that the list isn't empty.</p>
<p>See also <a href="qlinkedlist.html#first">first</a>() and <a href="qlinkedlist.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="last-2"></a>const T &amp; QLinkedList::last () const</h3>
<p>This is an overloaded function.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/pop_back"></a>
<h3 class="fn"><a name="pop_back"></a>void QLinkedList::pop_back ()</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#removeLast">removeLast</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/pop_front"></a>
<h3 class="fn"><a name="pop_front"></a>void QLinkedList::pop_front ()</h3>
<p>This function is provided for STL compatibility. It is equivalent to <a href="qlinkedlist.html#removeFirst">removeFirst</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/prepend"></a>
<h3 class="fn"><a name="prepend"></a>void QLinkedList::prepend ( const T &amp; <i>value</i> )</h3>
<p>Inserts <i>value</i> at the beginning of the list.</p>
<p>Example:</p>
<pre> QLinkedList&lt;QString&gt; list;
 list.prepend(&quot;one&quot;);
 list.prepend(&quot;two&quot;);
 list.prepend(&quot;three&quot;);
<span class="comment"> // list: [&quot;three&quot;, &quot;two&quot;, &quot;one&quot;]</span></pre>
<p>This is the same as list.insert(<a href="qlinkedlist.html#begin">begin</a>(), <i>value</i>).</p>
<p>See also <a href="qlinkedlist.html#append">append</a>() and <a href="qlinkedlist.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/push_back"></a>
<h3 class="fn"><a name="push_back"></a>void QLinkedList::push_back ( const T &amp; <i>value</i> )</h3>
<p>This function is provided for STL compatibility. It is equivalent to append(<i>value</i>).</p>
<a name="//apple_ref/cpp/instm/QLinkedList/push_front"></a>
<h3 class="fn"><a name="push_front"></a>void QLinkedList::push_front ( const T &amp; <i>value</i> )</h3>
<p>This function is provided for STL compatibility. It is equivalent to prepend(<i>value</i>).</p>
<a name="//apple_ref/cpp/instm/QLinkedList/removeAll"></a>
<h3 class="fn"><a name="removeAll"></a>int QLinkedList::removeAll ( const T &amp; <i>value</i> )</h3>
<p>Removes all occurrences of <i>value</i> in the list.</p>
<p>Example:</p>
<pre> QList&lt;QString&gt; list;
 list &lt;&lt; &quot;sun&quot; &lt;&lt; &quot;cloud&quot; &lt;&lt; &quot;sun&quot; &lt;&lt; &quot;rain&quot;;
 list.removeAll(&quot;sun&quot;);
<span class="comment"> // list: [&quot;cloud&quot;, &quot;rain&quot;]</span></pre>
<p>This function requires the value type to have an implementation of <tt>operator==()</tt>.</p>
<p>See also <a href="qlinkedlist.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/removeFirst"></a>
<h3 class="fn"><a name="removeFirst"></a>void QLinkedList::removeFirst ()</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>See also <a href="qlinkedlist.html#removeLast">removeLast</a>() and <a href="qlinkedlist.html#erase">erase</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/removeLast"></a>
<h3 class="fn"><a name="removeLast"></a>void QLinkedList::removeLast ()</h3>
<p>Removes the last item in the list.</p>
<p>See also <a href="qlinkedlist.html#removeFirst">removeFirst</a>() and <a href="qlinkedlist.html#erase">erase</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/removeOne"></a>
<h3 class="fn"><a name="removeOne"></a>bool QLinkedList::removeOne ( const T &amp; <i>value</i> )</h3>
<p>Removes the first occurrences of <i>value</i> in the list. Returns true on success; otherwise returns false.</p>
<p>Example:</p>
<pre> QList&lt;QString&gt; list;
 list &lt;&lt; &quot;sun&quot; &lt;&lt; &quot;cloud&quot; &lt;&lt; &quot;sun&quot; &lt;&lt; &quot;rain&quot;;
 list.removeOne(&quot;sun&quot;);
<span class="comment"> // list: [&quot;cloud&quot;, &quot;sun&quot;, &quot;rain&quot;]</span></pre>
<p>This function requires the value type to have an implementation of <tt>operator==()</tt>.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qlinkedlist.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/size"></a>
<h3 class="fn"><a name="size"></a>int QLinkedList::size () const</h3>
<p>Returns the number of items in the list.</p>
<p>See also <a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#count">count</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/startsWith"></a>
<h3 class="fn"><a name="startsWith"></a>bool QLinkedList::startsWith ( const T &amp; <i>value</i> ) const</h3>
<p>Returns true if the list is not empty and its first item is equal to <i>value</i>; otherwise returns false.</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qlinkedlist.html#isEmpty">isEmpty</a>() and <a href="qlinkedlist.html#first">first</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/takeFirst"></a>
<h3 class="fn"><a name="takeFirst"></a>T QLinkedList::takeFirst ()</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>See also <a href="qlinkedlist.html#takeLast">takeLast</a>() and <a href="qlinkedlist.html#removeFirst">removeFirst</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/takeLast"></a>
<h3 class="fn"><a name="takeLast"></a>T QLinkedList::takeLast ()</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>See also <a href="qlinkedlist.html#takeFirst">takeFirst</a>() and <a href="qlinkedlist.html#removeLast">removeLast</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/toStdList"></a>
<h3 class="fn"><a name="toStdList"></a>std::list&lt;T&gt; QLinkedList::toStdList () const</h3>
<p>Returns a std::list object with the data contained in this <a href="qlinkedlist.html">QLinkedList</a>. Example:</p>
<pre> QLinkedList&lt;double&gt; list;
 list &lt;&lt; 1.2 &lt;&lt; 0.5 &lt;&lt; 3.14;

 std::list&lt;double&gt; stdlist = list.toStdList();</pre>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qlinkedlist.html#fromStdList">fromStdList</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator!="></a>
<h3 class="fn"><a name="operator-not-eq"></a>bool QLinkedList::operator!= ( const QLinkedList&lt;T&gt; &amp; <i>other</i> ) const</h3>
<p>Returns true if <i>other</i> is not 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 <tt>operator==()</tt>.</p>
<p>See also <a href="qlinkedlist.html#operator-eq-eq">operator==</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator+"></a>
<h3 class="fn"><a name="operator-2b"></a>QLinkedList&lt;T&gt; QLinkedList::operator+ ( const QLinkedList&lt;T&gt; &amp; <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>See also <a href="qlinkedlist.html#operator-2b-eq">operator+=</a>().</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator+="></a>
<h3 class="fn"><a name="operator-2b-eq"></a>QLinkedList&lt;T&gt; &amp; QLinkedList::operator+= ( const QLinkedList&lt;T&gt; &amp; <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>See also <a href="qlinkedlist.html#operator-2b">operator+</a>() and <a href="qlinkedlist.html#append">append</a>().</p>
<h3 class="fn"><a name="operator-2b-eq-2"></a>QLinkedList&lt;T&gt; &amp; QLinkedList::operator+= ( const T &amp; <i>value</i> )</h3>
<p>This is an overloaded function.</p>
<p>Appends <i>value</i> to the list.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator&lt;&lt;"></a>
<h3 class="fn"><a name="operator-lt-lt"></a>QLinkedList&lt;T&gt; &amp; QLinkedList::operator&lt;&lt; ( const QLinkedList&lt;T&gt; &amp; <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>See also <a href="qlinkedlist.html#operator-2b-eq">operator+=</a>() and <a href="qlinkedlist.html#append">append</a>().</p>
<h3 class="fn"><a name="operator-lt-lt-2"></a>QLinkedList&lt;T&gt; &amp; QLinkedList::operator&lt;&lt; ( const T &amp; <i>value</i> )</h3>
<p>This is an overloaded function.</p>
<p>Appends <i>value</i> to the list.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator="></a>
<h3 class="fn"><a name="operator-eq"></a>QLinkedList&lt;T&gt; &amp; QLinkedList::operator= ( const QLinkedList&lt;T&gt; &amp; <i>other</i> )</h3>
<p>Assigns <i>other</i> to this list and returns a reference to this list.</p>
<a name="//apple_ref/cpp/instm/QLinkedList/operator=="></a>
<h3 class="fn"><a name="operator-eq-eq"></a>bool QLinkedList::operator== ( const QLinkedList&lt;T&gt; &amp; <i>other</i> ) const</h3>
<p>Returns true 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 <tt>operator==()</tt>.</p>
<p>See also <a href="qlinkedlist.html#operator-not-eq">operator!=</a>().</p>
<hr />
<h2>Related Non-Members</h2>
<h3 class="fn"><a name="operator-lt-lt-74"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QLinkedList&lt;T&gt; &amp; <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 <tt>operator&lt;&lt;()</tt>.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<h3 class="fn"><a name="operator-gt-gt-41"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QLinkedList&lt;T&gt; &amp; <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 <tt>operator&gt;&gt;()</tt>.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>