File: qvaluelistiterator.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (161 lines) | stat: -rw-r--r-- 8,847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QValueListIterator Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QValueListIterator Class Reference</h1><br clear="all">
<p>
The QValueListIterator class provides an iterator for <a href="qvaluelist.html">QValueList</a>.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qvaluelist-h.html">qvaluelist.h</a>&gt;</code>
<p><a href="qvaluelistiterator-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#0a7968"><b>QValueListIterator</b></a>()</div>
<li><div class="fn"><a href="#d5d3f2"><b>QValueListIterator</b></a>(NodePtrp)</div>
<li><div class="fn"><a href="#b90316"><b>QValueListIterator</b></a>(constQValueListIterator&lt;T&gt;&amp;it)</div>
<li><div class="fn">bool<a href="#0663fc"><b>operator==</b></a>(constQValueListIterator&lt;T&gt;&amp;it)const</div>
<li><div class="fn">bool<a href="#f223ee"><b>operator!=</b></a>(constQValueListIterator&lt;T&gt;&amp;it)const</div>
<li><div class="fn">constT&amp;<a href="#f41934"><b>operator*</b></a>()const</div>
<li><div class="fn">T&amp;<a href="#4a4351"><b>operator*</b></a>()</div>
<li><div class="fn">QValueListIterator&lt;T&gt;&amp;<a href="#5b8b88"><b>operator++</b></a>()</div>
<li><div class="fn">QValueListIterator&lt;T&gt;<a href="#325676"><b>operator++</b></a>(int)</div>
<li><div class="fn">QValueListIterator&lt;T&gt;&amp;<a href="#b9db1c"><b>operator--</b></a>()</div>
<li><div class="fn">QValueListIterator&lt;T&gt;<a href="#3b1f76"><b>operator--</b></a>(int)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QValueListIterator class provides an iterator for <a href="qvaluelist.html">QValueList</a>.
<p>
You can not create an iterator by yourself. Instead you have to
ask a list to give you one. An iterator has only the size of a pointer.
On 32 bit machines that means 4 bytes otherwise 8 bytes. That makes them
very fast. In fact they resemble the semantics of pointers as good as possible
and they are almost as fast as usual pointers.
<p>Example:
<pre>    #include &lt;qvaluelist.h&gt;
    #include &lt;qstring.h&gt;
    #include &lt;stdio.h&gt;

    class Employee
    {
    public:
        Employee(): s(0) {}
        Employee( const QString&amp; name, int salary )
            : n(name), s(salary)
        {}

        <a href="qstring.html">QString</a>     name()   const              { return n; }
        int         salary() const              { return s; }
        void        setSalary( int salary )     { s = salary; }
    private:
        <a href="qstring.html">QString</a>     n;
        int         s;
    };

    void main()
        {
            typedef QValueList&lt;Employee&gt; EmployeeList;
            EmployeeList list;          // list of Employee

            list.append( Employee("Bill", 50000) );
            list.append( Employee("Steve",80000) );
            list.append( Employee("Ron",  60000) );

            Employee joe( "Joe", 50000 );
            list.append( joe );
            joe.setSalary( 4000 );

            EmployeeList::Iterator it;
            for( it = list.begin(); it != list.end(); ++it )
                printf( "%s earns %d\n", (*it).name().latin1(), (*it).salary() );
        }
</pre>
<p>Program output:
<pre>        Bill earns 50000
        Steve earns 80000
        Ron earns 60000
        Joe earns 50000
</pre>
<p>In contrast to <a href="qlist.html">QList</a> there are no built in functions in QValueList to
traverse the list. The only way to do this is to use iterators.
QValueList is highly optimized for performance and memory usage.
On the other hand that means that you have to be a bit more careful
by what you are doing. QValueList does not know about all its iterators
and the iterators dont even know to which list they belong. That makes
things fast and slim but a bit dangerous because it is up to you to make
sure that iterators you are using are still valid. <a href="qlistiterator.html">QListIterator</a> will be able
to give warnings while QValueListIterator may end up in an undefined state.
<p>For every Iterator there is a ConstIterator. When accessing a QValueList
in a const environment or if the reference or pointer to the list is itself
const, then you have to use the ConstIterator. Its semantics are the same,
but it returns only const references to the item it points to.
<p>See also  <a href="qvaluelist.html">QValueList</a> and <a href="qvaluelistconstiterator.html">QValueListConstIterator</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="0a7968"></a>QValueListIterator::QValueListIterator()</h3>
<p>Creates un uninitialized iterator.
<h3 class="fn"><a name="d5d3f2"></a>QValueListIterator::QValueListIterator(NodePtrp)</h3>
<p>Internal function.
<h3 class="fn"><a name="b90316"></a>QValueListIterator::QValueListIterator(constQValueListIterator&lt;T&gt;&amp;it)</h3>
<p>Constructs a copy of the iterator <em>it.</em>
<h3 class="fn">bool<a name="f223ee"></a>QValueListIterator::operator!=(constQValueListIterator&lt;T&gt;&amp;it)const</h3>
<p>Compares both iterators and returns TRUE if they point to different items.
<h3 class="fn">T&amp;<a name="4a4351"></a>QValueListIterator::operator*()</h3>
<p>Asterix operator. Returns a reference to the current iterator item.
<h3 class="fn">constT&amp;<a name="f41934"></a>QValueListIterator::operator*()const</h3>
<p>Asterix operator. Returns a reference to the current iterator item.
<h3 class="fn">QValueListIterator&lt;T&gt;<a name="325676"></a>QValueListIterator::operator++(int)</h3>
<p>Postfix ++ makes the succeeding item current and returns
an iterator pointing to the new current item.
The iterator can not check wether it reached the end of the list. Incrementing
the iterator as returned by end() causes undefined results.
<h3 class="fn">QValueListIterator&lt;T&gt;&amp;<a name="5b8b88"></a>QValueListIterator::operator++()</h3>
<p>Prefix ++ makes the succeeding item current and returns
an iterator pointing to the new current item.
The iterator can not check wether it reached the end of the list. Incrementing
the iterator as returned by end() causes undefined results.
<h3 class="fn">QValueListIterator&lt;T&gt;<a name="3b1f76"></a>QValueListIterator::operator--(int)</h3>
<p>Postfix -- makes the previous item current and returns
an iterator pointing to the new current item.
The iterator can not check wether it reached the beginning of the list. Decrementing
the iterator as returned by begin() causes undefined results.
<h3 class="fn">QValueListIterator&lt;T&gt;&amp;<a name="b9db1c"></a>QValueListIterator::operator--()</h3>
<p>Prefix -- makes the previous item current and returns
an iterator pointing to the new current item.
The iterator can not check wether it reached the beginning of the list. Decrementing
the iterator as returned by begin() causes undefined results.
<h3 class="fn">bool<a name="0663fc"></a>QValueListIterator::operator==(constQValueListIterator&lt;T&gt;&amp;it)const</h3>
<p>Compares both iterators and returns TRUE if they point to the same item.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>