1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/q3ptrlist.qdoc -->
7
<title>Qt 4.0: Q3PtrListIterator Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3PtrListIterator Class Reference</h1>
21
<p>The Q3PtrListIterator class provides an iterator for <a href="q3ptrlist.html">Q3PtrList</a> collections. <a href="#details">More...</a></p>
22
<pre>#include <Q3PtrListIterator></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
24
<p>Inherited by <a href="q3strlistiterator.html">Q3StrListIterator</a>.</p>
26
<li><a href="q3ptrlistiterator-members.html">List of all members, including inherited members</a></li>
28
<a name="public-functions"></a>
29
<h3>Public Functions</h3>
31
<li><div class="fn"/><b><a href="q3ptrlistiterator.html#Q3PtrListIterator">Q3PtrListIterator</a></b> ( const Q3PtrList<type> & <i>list</i> )</li>
32
<li><div class="fn"/><b><a href="q3ptrlistiterator.html#dtor.Q3PtrListIterator">~Q3PtrListIterator</a></b> ()</li>
33
<li><div class="fn"/>bool <b><a href="q3ptrlistiterator.html#atFirst">atFirst</a></b> () const</li>
34
<li><div class="fn"/>bool <b><a href="q3ptrlistiterator.html#atLast">atLast</a></b> () const</li>
35
<li><div class="fn"/>uint <b><a href="q3ptrlistiterator.html#count">count</a></b> () const</li>
36
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#current">current</a></b> () const</li>
37
<li><div class="fn"/>bool <b><a href="q3ptrlistiterator.html#isEmpty">isEmpty</a></b> () const</li>
38
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#toFirst">toFirst</a></b> ()</li>
39
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#toLast">toLast</a></b> ()</li>
40
<li><div class="fn"/><b><a href="q3ptrlistiterator.html#operator-type--2a">operator type *</a></b> () const</li>
41
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator-28-29">operator()</a></b> ()</li>
42
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator-2a">operator*</a></b> ()</li>
43
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator-2b-2b">operator++</a></b> ()</li>
44
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator-2b-eq">operator+=</a></b> ( uint <i>jump</i> )</li>
45
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator--">operator--</a></b> ()</li>
46
<li><div class="fn"/>type * <b><a href="q3ptrlistiterator.html#operator--eq">operator-=</a></b> ( uint <i>jump</i> )</li>
47
<li><div class="fn"/>Q3PtrListIterator<type> & <b><a href="q3ptrlistiterator.html#operator-eq">operator=</a></b> ( const Q3PtrListIterator<type> & <i>it</i> )</li>
49
<a name="details"></a>
51
<h2>Detailed Description</h2>
52
<p>The Q3PtrListIterator class provides an iterator for <a href="q3ptrlist.html">Q3PtrList</a> collections.</p>
53
<p>Define a template instance Q3PtrListIterator<X> to create a list iterator that operates on <a href="q3ptrlist.html">Q3PtrList</a><X> (list of X*).</p>
54
<p>The following example is similar to the example in the <a href="q3ptrlist.html">Q3PtrList</a> class documentation, but it uses Q3PtrListIterator. The class Employee is defined there.</p>
55
<pre> Q3PtrList<Employee> list;
57
list.append( new Employee("John", "Doe", 50000) );
58
list.append( new Employee("Jane", "Williams", 80000) );
59
list.append( new Employee("Tom", "Jones", 60000) );
61
Q3PtrListIterator<Employee> it( list );
63
while ( (employee = it.current()) != 0 ) {
65
cout << employee->surname().latin1() << ", " <<
66
employee->forename().latin1() << " earns " <<
67
employee->salary() << endl;
70
<pre> Doe, John earns 50000
71
Williams, Jane earns 80000
72
Jones, Tom earns 60000</pre>
73
<p>Using a list iterator is a more robust way of traversing the list than using the <a href="q3ptrlist.html">Q3PtrList</a> member functions <a href="q3ptrlist.html#first">first</a>(), <a href="q3ptrlist.html#next">next</a>(), <a href="q3ptrlist.html#current">current</a>(), etc., as many iterators can traverse the same list independently.</p>
74
<p>An iterator has its own current list item and can get the next and previous list items. It doesn't modify the list in any way.</p>
75
<p>When an item is removed from the list, all iterators that point to that item are updated to point to <a href="q3ptrlist.html#current">Q3PtrList::current</a>() instead to avoid dangling references.</p>
76
<p>See also <a href="q3ptrlist.html">Q3PtrList</a>.</p>
78
<h2>Member Function Documentation</h2>
79
<h3 class="fn"><a name="Q3PtrListIterator"></a>Q3PtrListIterator::Q3PtrListIterator ( const <a href="q3ptrlist.html">Q3PtrList</a><type> & <i>list</i> )</h3>
80
<p>Constructs an iterator for <i>list</i>. The current iterator item is set to point on the first item in the <i>list</i>.</p>
81
<h3 class="fn"><a name="dtor.Q3PtrListIterator"></a>Q3PtrListIterator::~Q3PtrListIterator ()</h3>
82
<p>Destroys the iterator.</p>
83
<h3 class="fn"><a name="atFirst"></a>bool Q3PtrListIterator::atFirst () const</h3>
84
<p>Returns TRUE if the current iterator item is the first list item; otherwise returns FALSE.</p>
85
<p>See also <a href="q3ptrlistiterator.html#toFirst">toFirst</a>() and <a href="q3ptrlistiterator.html#atLast">atLast</a>().</p>
86
<h3 class="fn"><a name="atLast"></a>bool Q3PtrListIterator::atLast () const</h3>
87
<p>Returns TRUE if the current iterator item is the last list item; otherwise returns FALSE.</p>
88
<p>See also <a href="q3ptrlistiterator.html#toLast">toLast</a>() and <a href="q3ptrlistiterator.html#atFirst">atFirst</a>().</p>
89
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrListIterator::count () const</h3>
90
<p>Returns the number of items in the list this iterator operates on.</p>
91
<p>See also <a href="q3ptrlistiterator.html#isEmpty">isEmpty</a>().</p>
92
<h3 class="fn"><a name="current"></a>type * Q3PtrListIterator::current () const</h3>
93
<p>Returns a pointer to the current iterator item. If the iterator is positioned before the first item in the list or after the last item in the list, 0 is returned.</p>
94
<h3 class="fn"><a name="isEmpty"></a>bool Q3PtrListIterator::isEmpty () const</h3>
95
<p>Returns TRUE if the list is empty; otherwise returns FALSE.</p>
96
<p>See also <a href="q3ptrlistiterator.html#count">count</a>().</p>
97
<h3 class="fn"><a name="toFirst"></a>type * Q3PtrListIterator::toFirst ()</h3>
98
<p>Sets the current iterator item to point to the first list item and returns a pointer to the item. Sets the current item to 0 and returns 0 if the list is empty.</p>
99
<p>See also <a href="q3ptrlistiterator.html#toLast">toLast</a>() and <a href="q3ptrlistiterator.html#atFirst">atFirst</a>().</p>
100
<h3 class="fn"><a name="toLast"></a>type * Q3PtrListIterator::toLast ()</h3>
101
<p>Sets the current iterator item to point to the last list item and returns a pointer to the item. Sets the current item to 0 and returns 0 if the list is empty.</p>
102
<p>See also <a href="q3ptrlistiterator.html#toFirst">toFirst</a>() and <a href="q3ptrlistiterator.html#atLast">atLast</a>().</p>
103
<h3 class="fn"><a name="operator-type--2a"></a>Q3PtrListIterator::operator type * () const</h3>
104
<p>Cast operator. Returns a pointer to the current iterator item. Same as <a href="q3ptrlistiterator.html#current">current</a>().</p>
105
<h3 class="fn"><a name="operator-28-29"></a>type * Q3PtrListIterator::operator() ()</h3>
106
<p>Makes the succeeding item current and returns the original current item.</p>
107
<p>If the current iterator item was the last item in the list or if it was 0, 0 is returned.</p>
108
<h3 class="fn"><a name="operator-2a"></a>type * Q3PtrListIterator::operator* ()</h3>
109
<p>Asterisk operator. Returns a pointer to the current iterator item. Same as <a href="q3ptrlistiterator.html#current">current</a>().</p>
110
<h3 class="fn"><a name="operator-2b-2b"></a>type * Q3PtrListIterator::operator++ ()</h3>
111
<p>Prefix ++ makes the succeeding item current and returns the new current item.</p>
112
<p>If the current iterator item was the last item in the list or if it was 0, 0 is returned.</p>
113
<h3 class="fn"><a name="operator-2b-eq"></a>type * Q3PtrListIterator::operator+= ( <a href="qtglobal.html#uint-typedef">uint</a> <i>jump</i> )</h3>
114
<p>Sets the current item to the item <i>jump</i> positions after the current item and returns a pointer to that item.</p>
115
<p>If that item is beyond the last item or if the list is empty, it sets the current item to 0 and returns 0</p>
116
<h3 class="fn"><a name="operator--"></a>type * Q3PtrListIterator::operator-- ()</h3>
117
<p>Prefix - makes the preceding item current and returns the new current item.</p>
118
<p>If the current iterator item was the first item in the list or if it was 0, 0 is returned.</p>
119
<h3 class="fn"><a name="operator--eq"></a>type * Q3PtrListIterator::operator-= ( <a href="qtglobal.html#uint-typedef">uint</a> <i>jump</i> )</h3>
120
<p>Returns the item <i>jump</i> positions before the current item or 0 if it is beyond the first item. Makes this the current item.</p>
121
<h3 class="fn"><a name="operator-eq"></a>Q3PtrListIterator<type> & Q3PtrListIterator::operator= ( const Q3PtrListIterator<type> & <i>it</i> )</h3>
122
<p>Assignment. Makes a copy of the iterator <i>it</i> and returns a reference to this iterator.</p>
123
<p /><address><hr /><div align="center">
124
<table width="100%" cellspacing="0" border="0"><tr class="address">
125
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
126
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
127
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
128
</tr></table></div></address></body>