Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ac91357d6caede925de099a02fced14e > files > 4307

qt4-doc-4.2.1-1.el5_7.1.x86_64.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">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/corelib/tools/qlistdata.cpp -->
<head>
  <title>Qt 4.2: QList::const_iterator Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" 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="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QList::const_iterator Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1>
<p>The QList::const_iterator class provides an STL-style const iterator for <a href="qlist.html">QList</a> and <a href="qqueue.html">QQueue</a>. <a href="#details">More...</a></p>
<pre> #include &lt;<a href="qlist.html">QList</a>&gt;</pre><ul>
<li><a href="qlist-const-iterator-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qlist-const-iterator.html#const_iterator">const_iterator</a></b> ()</li>
<li><div class="fn"/><b><a href="qlist-const-iterator.html#const_iterator-3">const_iterator</a></b> ( const const_iterator &amp; <i>other</i> )</li>
<li><div class="fn"/><b><a href="qlist-const-iterator.html#const_iterator-4">const_iterator</a></b> ( const iterator &amp; <i>other</i> )</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-not-eq">operator!=</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>const T &amp; <b><a href="qlist-const-iterator.html#operator-2a">operator*</a></b> () const</li>
<li><div class="fn"/>const_iterator <b><a href="qlist-const-iterator.html#operator-2b">operator+</a></b> ( int <i>j</i> ) const</li>
<li><div class="fn"/>const_iterator &amp; <b><a href="qlist-const-iterator.html#operator-2b-2b">operator++</a></b> ()</li>
<li><div class="fn"/>const_iterator <b><a href="qlist-const-iterator.html#operator-2b-2b-2">operator++</a></b> ( int )</li>
<li><div class="fn"/>const_iterator &amp; <b><a href="qlist-const-iterator.html#operator-2b-eq">operator+=</a></b> ( int <i>j</i> )</li>
<li><div class="fn"/>const_iterator <b><a href="qlist-const-iterator.html#operator-">operator-</a></b> ( int <i>j</i> ) const</li>
<li><div class="fn"/>int <b><a href="qlist-const-iterator.html#operator--2">operator-</a></b> ( const_iterator <i>other</i> ) const</li>
<li><div class="fn"/>const_iterator &amp; <b><a href="qlist-const-iterator.html#operator--">operator--</a></b> ()</li>
<li><div class="fn"/>const_iterator <b><a href="qlist-const-iterator.html#operator---2">operator--</a></b> ( int )</li>
<li><div class="fn"/>const_iterator &amp; <b><a href="qlist-const-iterator.html#operator--eq">operator-=</a></b> ( int <i>j</i> )</li>
<li><div class="fn"/>const T * <b><a href="qlist-const-iterator.html#operator--gt">operator-&gt;</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-lt">operator&lt;</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-lt-eq">operator&lt;=</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-eq-eq">operator==</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-gt">operator&gt;</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>bool <b><a href="qlist-const-iterator.html#operator-gt-eq">operator&gt;=</a></b> ( const const_iterator &amp; <i>other</i> ) const</li>
<li><div class="fn"/>const T &amp; <b><a href="qlist-const-iterator.html#operator-5b-5d">operator[]</a></b> ( int <i>j</i> ) const</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QList::const_iterator class provides an STL-style const iterator for <a href="qlist.html">QList</a> and <a href="qqueue.html">QQueue</a>.</p>
<p><a href="qlist.html">QList</a> provides both <a href="containers.html#stl-style-iterators">STL-style iterators</a> and <a href="containers.html#java-style-iterators">Java-style iterators</a>. The STL-style iterators are more low-level and more cumbersome to use; on the other hand, they are slightly faster and, for developers who already know STL, have the advantage of familiarity.</p>
<p><a href="qlist.html">QList</a>&lt;T&gt;::const_iterator allows you to iterate over a <a href="qlist.html">QList</a>&lt;T&gt; (or a <a href="qqueue.html">QQueue</a>&lt;T&gt;). If you want to modify the <a href="qlist.html">QList</a> as you iterate over it, use <a href="qlist-iterator.html">QList::iterator</a> instead. It is generally good practice to use QList::const_iterator on a non-const <a href="qlist.html">QList</a> as well, unless you need to change the <a href="qlist.html">QList</a> through the iterator. Const iterators are slightly faster, and can improve code readability.</p>
<p>The default QList::const_iterator constructor creates an uninitialized iterator. You must initialize it using a <a href="qlist.html">QList</a> function like <a href="qlist.html#constBegin">QList::constBegin</a>(), <a href="qlist.html#constEnd">QList::constEnd</a>(), or <a href="qlist.html#insert">QList::insert</a>() before you can start iterating. Here's a typical loop that prints all the items stored in a list:</p>
<pre> QList&lt;QString&gt; list;
 list.append(&quot;January&quot;);
 list.append(&quot;February&quot;);
 ...
 list.append(&quot;December&quot;);

 QList&lt;QString&gt;::const_iterator i;
 for (i = list.constBegin(); i != list.constEnd(); ++i)
     cout &lt;&lt; *i &lt;&lt; endl;</pre>
<p>Most <a href="qlist.html">QList</a> functions accept an integer index rather than an iterator. For that reason, iterators are rarely useful in connection with <a href="qlist.html">QList</a>. One place where STL-style iterators do make sense is as arguments to <a href="qtalgorithms.html">generic algorithms</a>.</p>
<p>For example, here's how to delete all the widgets stored in a <a href="qlist.html">QList</a>&lt;<a href="qwidget.html">QWidget</a> *&gt;:</p>
<pre> QList&lt;QWidget *&gt; list;
 ...
 qDeleteAll(list.constBegin(), list.constEnd());</pre>
<p>Multiple iterators can be used on the same list. However, be aware that any non-const function call performed on the <a href="qlist.html">QList</a> will render all existing iterators undefined. If you need to keep iterators over a long period of time, we recommend that you use <a href="qlinkedlist.html">QLinkedList</a> rather than <a href="qlist.html">QList</a>.</p>
<p>See also <a href="qlist-iterator.html">QList::iterator</a> and <a href="qlistiterator.html">QListIterator</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="const_iterator"></a>const_iterator::const_iterator ()</h3>
<p>Constructs an uninitialized iterator.</p>
<p>Functions like operator*() and operator++() should not be called on an uninitialized iterartor. Use operator=() to assign a value to it before using it.</p>
<p>See also <a href="qlist.html#constBegin">QList::constBegin</a>() and <a href="qlist.html#constEnd">QList::constEnd</a>().</p>
<h3 class="fn"><a name="const_iterator-3"></a>const_iterator::const_iterator ( const const_iterator &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<h3 class="fn"><a name="const_iterator-4"></a>const_iterator::const_iterator ( const <a href="qlist-iterator.html">iterator</a> &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<h3 class="fn"><a name="operator-not-eq"></a>bool const_iterator::operator!= ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if <i>other</i> points to a different item than this iterator; otherwise returns false.</p>
<p>See also <a href="qlist-const-iterator.html#operator-eq-eq">operator==</a>().</p>
<h3 class="fn"><a name="operator-2a"></a>const T &amp; const_iterator::operator* () const</h3>
<p>Returns the current item.</p>
<p>See also <a href="qlist-const-iterator.html#operator--gt">operator-&gt;</a>().</p>
<h3 class="fn"><a name="operator-2b"></a>const_iterator const_iterator::operator+ ( int <i>j</i> ) const</h3>
<p>Returns an iterator to the item at <i>j</i> positions forward from this iterator. (If <i>j</i> is negative, the iterator goes backward.)</p>
<p>See also <a href="qlist-const-iterator.html#operator-">operator-</a>() and <a href="qlist-const-iterator.html#operator-2b-eq">operator+=</a>().</p>
<h3 class="fn"><a name="operator-2b-2b"></a>const_iterator &amp; const_iterator::operator++ ()</h3>
<p>The prefix ++ operator (<tt>++it</tt>) advances the iterator to the next item in the list and returns an iterator to the new current item.</p>
<p>Calling this function on <a href="qlist.html#end">QList::end</a>() leads to undefined results.</p>
<p>See also <a href="qlist-const-iterator.html#operator--">operator--</a>().</p>
<h3 class="fn"><a name="operator-2b-2b-2"></a>const_iterator const_iterator::operator++ ( int )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>The postfix ++ operator (<tt>it++</tt>) advances the iterator to the next item in the list and returns an iterator to the previously current item.</p>
<h3 class="fn"><a name="operator-2b-eq"></a>const_iterator &amp; const_iterator::operator+= ( int <i>j</i> )</h3>
<p>Advances the iterator by <i>j</i> items. (If <i>j</i> is negative, the iterator goes backward.)</p>
<p>See also <a href="qlist-const-iterator.html#operator--eq">operator-=</a>() and <a href="qlist-const-iterator.html#operator-2b">operator+</a>().</p>
<h3 class="fn"><a name="operator-"></a>const_iterator const_iterator::operator- ( int <i>j</i> ) const</h3>
<p>Returns an iterator to the item at <i>j</i> positions backward from this iterator. (If <i>j</i> is negative, the iterator goes forward.)</p>
<p>See also <a href="qlist-const-iterator.html#operator-2b">operator+</a>() and <a href="qlist-const-iterator.html#operator--eq">operator-=</a>().</p>
<h3 class="fn"><a name="operator--2"></a>int const_iterator::operator- ( const_iterator <i>other</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the number of items between the item pointed to by <i>other</i> and the item pointed to by this iterator.</p>
<h3 class="fn"><a name="operator--"></a>const_iterator &amp; const_iterator::operator-- ()</h3>
<p>The prefix -- operator (<tt>--it</tt>) makes the preceding item current and returns an iterator to the new current item.</p>
<p>Calling this function on <a href="qlist.html#begin">QList::begin</a>() leads to undefined results.</p>
<p>See also <a href="qlist-const-iterator.html#operator-2b-2b">operator++</a>().</p>
<h3 class="fn"><a name="operator---2"></a>const_iterator const_iterator::operator-- ( int )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>The postfix -- operator (<tt>it--</tt>) makes the preceding item current and returns an iterator to the previously current item.</p>
<h3 class="fn"><a name="operator--eq"></a>const_iterator &amp; const_iterator::operator-= ( int <i>j</i> )</h3>
<p>Makes the iterator go back by <i>j</i> items. (If <i>j</i> is negative, the iterator goes forward.)</p>
<p>See also <a href="qlist-const-iterator.html#operator-2b-eq">operator+=</a>() and <a href="qlist-const-iterator.html#operator-">operator-</a>().</p>
<h3 class="fn"><a name="operator--gt"></a>const T * const_iterator::operator-&gt; () const</h3>
<p>Returns a pointer to the current item.</p>
<p>See also <a href="qlist-const-iterator.html#operator-2a">operator*</a>().</p>
<h3 class="fn"><a name="operator-lt"></a>bool const_iterator::operator&lt; ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if the item pointed to by this iterator is less than the item pointed to by the <i>other</i> iterator.</p>
<h3 class="fn"><a name="operator-lt-eq"></a>bool const_iterator::operator&lt;= ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if the item pointed to by this iterator is less than or equal to the item pointed to by the <i>other</i> iterator.</p>
<h3 class="fn"><a name="operator-eq-eq"></a>bool const_iterator::operator== ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if <i>other</i> points to the same item as this iterator; otherwise returns false.</p>
<p>See also <a href="qlist-const-iterator.html#operator-not-eq">operator!=</a>().</p>
<h3 class="fn"><a name="operator-gt"></a>bool const_iterator::operator&gt; ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if the item pointed to by this iterator is greater than the item pointed to by the <i>other</i> iterator.</p>
<h3 class="fn"><a name="operator-gt-eq"></a>bool const_iterator::operator&gt;= ( const const_iterator &amp; <i>other</i> ) const</h3>
<p>Returns true if the item pointed to by this iterator is greater than or equal to the item pointed to by the <i>other</i> iterator.</p>
<h3 class="fn"><a name="operator-5b-5d"></a>const T &amp; const_iterator::operator[] ( int <i>j</i> ) const</h3>
<p>Returns the item at position *this + <i>j</i>.</p>
<p>This function is provided to make <a href="qlist.html">QList</a> iterators behave like C++ pointers.</p>
<p>See also <a href="qlist-const-iterator.html#operator-2b">operator+</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>