Sophie

Sophie

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

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">
<!-- qiterator.qdoc -->
<head>
  <title>Qt 4.6: QMutableLinkedListIterator Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QMutableLinkedListIterator"></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">QMutableLinkedListIterator Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span>
</h1>
<p>The QMutableLinkedListIterator class provides a Java-style non-const iterator for <a href="qlinkedlist.html">QLinkedList</a>. <a href="#details">More...</a></p>
<pre> #include &lt;QMutableLinkedListIterator&gt;</pre><ul>
<li><a href="qmutablelinkedlistiterator-members.html">List of all members, including inherited members</a></li>
</ul>
<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="qmutablelinkedlistiterator.html#QMutableLinkedListIterator">QMutableLinkedListIterator</a></b> ( QLinkedList&lt;T&gt; &amp; <i>list</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#dtor.QMutableLinkedListIterator">~QMutableLinkedListIterator</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#findNext">findNext</a></b> ( 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="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a></b> ( 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="qmutablelinkedlistiterator.html#hasNext">hasNext</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#hasPrevious">hasPrevious</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#insert">insert</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="qmutablelinkedlistiterator.html#next">next</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#peekNext">peekNext</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#peekPrevious">peekPrevious</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#previous">previous</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#remove">remove</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#setValue">setValue</a></b> ( const T &amp; <i>value</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#toBack">toBack</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#toFront">toFront</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#value">value</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#value-2">value</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QMutableLinkedListIterator &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qmutablelinkedlistiterator.html#operator-eq">operator=</a></b> ( QLinkedList&lt;T&gt; &amp; <i>list</i> )</td></tr>
</table>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QMutableLinkedListIterator class provides a Java-style non-const iterator for <a href="qlinkedlist.html">QLinkedList</a>.</p>
<p><a href="qlinkedlist.html">QLinkedList</a> has both <a href="containers.html#java-style-iterators">Java-style iterators</a> and <a href="containers.html#stl-style-iterators">STL-style iterators</a>. The Java-style iterators are more high-level and easier to use than the STL-style iterators; on the other hand, they are slightly less efficient.</p>
<p>QMutableLinkedListIterator&lt;T&gt; allows you to iterate over a <a href="qlinkedlist.html">QLinkedList</a>&lt;T&gt; and modify the list. If you don't want to modify the list (or have a const <a href="qlinkedlist.html">QLinkedList</a>), use the slightly faster <a href="qlinkedlistiterator.html">QLinkedListIterator</a>&lt;T&gt; instead.</p>
<p>The QMutableLinkedListIterator constructor takes a <a href="qlinkedlist.html">QLinkedList</a> as argument. After construction, the iterator is located at the very beginning of the list (before the first item). Here's how to iterate over all the elements sequentially:</p>
<pre> QLinkedList&lt;float&gt; list;
 ...
 QMutableLinkedListIterator&lt;float&gt; i(list);
 while (i.hasNext())
     qDebug() &lt;&lt; i.next();</pre>
<p>The <a href="qmutablelinkedlistiterator.html#next">next</a>() function returns the next item in the list and advances the iterator. Unlike STL-style iterators, Java-style iterators point <i>between</i> items rather than directly <i>at</i> items. The first call to <a href="qmutablelinkedlistiterator.html#next">next</a>() advances the iterator to the position between the first and second item, and returns the first item; the second call to <a href="qmutablelinkedlistiterator.html#next">next</a>() advances the iterator to the position between the second and third item, returning the second item; and so on.</p>
<p align="center"><img src="images/javaiterators1.png" /></p><p>Here's how to iterate over the elements in reverse order:</p>
<pre> QMutableLinkedListIterator&lt;float&gt; i(list);
 i.toBack();
 while (i.hasPrevious())
     qDebug() &lt;&lt; i.previous();</pre>
<p>If you want to find all occurrences of a particular value, use <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>() or <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>() in a loop.</p>
<p>If you want to remove items as you iterate over the list, use <a href="qmutablelinkedlistiterator.html#remove">remove</a>(). If you want to modify the value of an item, use <a href="qmutablelinkedlistiterator.html#setValue">setValue</a>(). If you want to insert a new item in the list, use <a href="qmutablelinkedlistiterator.html#insert">insert</a>().</p>
<p>Example:</p>
<pre> QMutableLinkedListIterator&lt;int&gt; i(list);
 while (i.hasNext()) {
     int val = i.next();
     if (val &lt; 0) {
         i.setValue(-val);
     } else if (val == 0) {
         i.remove();
     }
 }</pre>
<p>The example traverses a list, replacing negative numbers with their absolute values, and eliminating zeroes.</p>
<p>Only one mutable iterator can be active on a given list at any time. Furthermore, no changes should be done directly to the list while the iterator is active (as opposed to through the iterator), since this could invalidate the iterator and lead to undefined behavior.</p>
<p>See also <a href="qlinkedlistiterator.html">QLinkedListIterator</a> and <a href="qlinkedlist-iterator.html">QLinkedList::iterator</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/QMutableLinkedListIterator"></a>
<h3 class="fn"><a name="QMutableLinkedListIterator"></a>QMutableLinkedListIterator::QMutableLinkedListIterator ( <a href="qlinkedlist.html">QLinkedList</a>&lt;T&gt; &amp; <i>list</i> )</h3>
<p>Constructs an iterator for traversing <i>list</i>. The iterator is set to be at the front of the list (before the first item).</p>
<p>See also <a href="qmutablelinkedlistiterator.html#operator-eq">operator=</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/~QMutableLinkedListIterator"></a>
<h3 class="fn"><a name="dtor.QMutableLinkedListIterator"></a>QMutableLinkedListIterator::~QMutableLinkedListIterator ()</h3>
<p>Destroys the iterator.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#operator-eq">operator=</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/findNext"></a>
<h3 class="fn"><a name="findNext"></a>bool QMutableLinkedListIterator::findNext ( const T &amp; <i>value</i> )</h3>
<p>Searches for <i>value</i> starting from the current iterator position forward. Returns true if <i>value</i> is found; otherwise returns false.</p>
<p>After the call, if <i>value</i> was found, the iterator is positioned just after the matching item; otherwise, the iterator is positioned at the back of the container.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/findPrevious"></a>
<h3 class="fn"><a name="findPrevious"></a>bool QMutableLinkedListIterator::findPrevious ( const T &amp; <i>value</i> )</h3>
<p>Searches for <i>value</i> starting from the current iterator position backward. Returns true if <i>value</i> is found; otherwise returns false.</p>
<p>After the call, if <i>value</i> was found, the iterator is positioned just before the matching item; otherwise, the iterator is positioned at the front of the container.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/hasNext"></a>
<h3 class="fn"><a name="hasNext"></a>bool QMutableLinkedListIterator::hasNext () const</h3>
<p>Returns true if there is at least one item ahead of the iterator, i.e&#x2e; the iterator is <i>not</i> at the back of the container; otherwise returns false.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasPrevious">hasPrevious</a>() and <a href="qmutablelinkedlistiterator.html#next">next</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/hasPrevious"></a>
<h3 class="fn"><a name="hasPrevious"></a>bool QMutableLinkedListIterator::hasPrevious () const</h3>
<p>Returns true if there is at least one item behind the iterator, i.e&#x2e; the iterator is <i>not</i> at the front of the container; otherwise returns false.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasNext">hasNext</a>() and <a href="qmutablelinkedlistiterator.html#previous">previous</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/insert"></a>
<h3 class="fn"><a name="insert"></a>void QMutableLinkedListIterator::insert ( const T &amp; <i>value</i> )</h3>
<p>Inserts <i>value</i> at the current iterator position. After the call, the iterator is located just after the inserted item.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#remove">remove</a>() and <a href="qmutablelinkedlistiterator.html#setValue">setValue</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/next"></a>
<h3 class="fn"><a name="next"></a>T &amp; QMutableLinkedListIterator::next ()</h3>
<p>Returns a reference to the next item, and advances the iterator by one position.</p>
<p>Calling this function on an iterator located at the back of the container leads to undefined results.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasNext">hasNext</a>(), <a href="qmutablelinkedlistiterator.html#peekNext">peekNext</a>(), and <a href="qmutablelinkedlistiterator.html#previous">previous</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/peekNext"></a>
<h3 class="fn"><a name="peekNext"></a>T &amp; QMutableLinkedListIterator::peekNext () const</h3>
<p>Returns a reference to the next item, without moving the iterator.</p>
<p>Calling this function on an iterator located at the back of the container leads to undefined results.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasNext">hasNext</a>(), <a href="qmutablelinkedlistiterator.html#next">next</a>(), and <a href="qmutablelinkedlistiterator.html#peekPrevious">peekPrevious</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/peekPrevious"></a>
<h3 class="fn"><a name="peekPrevious"></a>T &amp; QMutableLinkedListIterator::peekPrevious () const</h3>
<p>Returns a reference to the previous item, without moving the iterator.</p>
<p>Calling this function on an iterator located at the front of the container leads to undefined results.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasPrevious">hasPrevious</a>(), <a href="qmutablelinkedlistiterator.html#previous">previous</a>(), and <a href="qmutablelinkedlistiterator.html#peekNext">peekNext</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/previous"></a>
<h3 class="fn"><a name="previous"></a>T &amp; QMutableLinkedListIterator::previous ()</h3>
<p>Returns a reference to the previous item and moves the iterator back by one position.</p>
<p>Calling this function on an iterator located at the front of the container leads to undefined results.</p>
<p>See also <a href="qmutablelinkedlistiterator.html#hasPrevious">hasPrevious</a>(), <a href="qmutablelinkedlistiterator.html#peekPrevious">peekPrevious</a>(), and <a href="qmutablelinkedlistiterator.html#next">next</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/remove"></a>
<h3 class="fn"><a name="remove"></a>void QMutableLinkedListIterator::remove ()</h3>
<p>Removes the last item that was jumped over using one of the traversal functions (<a href="qmutablelinkedlistiterator.html#next">next</a>(), <a href="qmutablelinkedlistiterator.html#previous">previous</a>(), <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>(), <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>()).</p>
<p>Example:</p>
<pre> QMutableLinkedListIterator&lt;int&gt; i(list);
 while (i.hasNext()) {
     int val = i.next();
     if (val &lt; -32768 || val &gt; 32767)
         i.remove();
 }</pre>
<p>See also <a href="qmutablelinkedlistiterator.html#insert">insert</a>() and <a href="qmutablelinkedlistiterator.html#setValue">setValue</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/setValue"></a>
<h3 class="fn"><a name="setValue"></a>void QMutableLinkedListIterator::setValue ( const T &amp; <i>value</i> ) const</h3>
<p>Replaces the value of the last item that was jumped over using one of the traversal functions with <i>value</i>.</p>
<p>The traversal functions are <a href="qmutablelinkedlistiterator.html#next">next</a>(), <a href="qmutablelinkedlistiterator.html#previous">previous</a>(), <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>(), and <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>().</p>
<p>Example:</p>
<pre> QMutableLinkedListIterator&lt;double&gt; i(list);
 while (i.hasNext()) {
     double val = i.next();
     i.setValue(sqrt(val));
 }</pre>
<p>See also <a href="qmutablelinkedlistiterator.html#value">value</a>(), <a href="qmutablelinkedlistiterator.html#remove">remove</a>(), and <a href="qmutablelinkedlistiterator.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/toBack"></a>
<h3 class="fn"><a name="toBack"></a>void QMutableLinkedListIterator::toBack ()</h3>
<p>Moves the iterator to the back of the container (after the last item).</p>
<p>See also <a href="qmutablelinkedlistiterator.html#toFront">toFront</a>() and <a href="qmutablelinkedlistiterator.html#previous">previous</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/toFront"></a>
<h3 class="fn"><a name="toFront"></a>void QMutableLinkedListIterator::toFront ()</h3>
<p>Moves the iterator to the front of the container (before the first item).</p>
<p>See also <a href="qmutablelinkedlistiterator.html#toBack">toBack</a>() and <a href="qmutablelinkedlistiterator.html#next">next</a>().</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/value"></a>
<h3 class="fn"><a name="value"></a>const T &amp; QMutableLinkedListIterator::value () const</h3>
<p>Returns the value of the last item that was jumped over using one of the traversal functions (<a href="qmutablelinkedlistiterator.html#next">next</a>(), <a href="qmutablelinkedlistiterator.html#previous">previous</a>(), <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>(), <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>()).</p>
<p>After a call to <a href="qmutablelinkedlistiterator.html#next">next</a>() or <a href="qmutablelinkedlistiterator.html#findNext">findNext</a>(), value() is equivalent to <a href="qmutablelinkedlistiterator.html#peekPrevious">peekPrevious</a>(). After a call to <a href="qmutablelinkedlistiterator.html#previous">previous</a>() or <a href="qmutablelinkedlistiterator.html#findPrevious">findPrevious</a>(), value() is equivalent to <a href="qmutablelinkedlistiterator.html#peekNext">peekNext</a>().</p>
<p>See also <a href="qmutablelinkedlistiterator.html#setValue">setValue</a>().</p>
<h3 class="fn"><a name="value-2"></a>T &amp; QMutableLinkedListIterator::value ()</h3>
<p>This is an overloaded function.</p>
<p>Returns a non-const reference to the value of the last item that was jumped over using one of the traversal functions.</p>
<a name="//apple_ref/cpp/instm/QMutableLinkedListIterator/operator="></a>
<h3 class="fn"><a name="operator-eq"></a>QMutableLinkedListIterator &amp; QMutableLinkedListIterator::operator= ( <a href="qlinkedlist.html">QLinkedList</a>&lt;T&gt; &amp; <i>list</i> )</h3>
<p>Makes the iterator operate on <i>list</i>. The iterator is set to be at the front of the list (before the first item).</p>
<p>See also <a href="qmutablelinkedlistiterator.html#toFront">toFront</a>() and <a href="qmutablelinkedlistiterator.html#toBack">toBack</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>