QtBase  v6.3.1
doc_src_qiterator.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50 
53 ...
54 QListIterator<float> i(list);
55 while (i.hasNext())
56  float f = i.next();
58 
59 
61 QListIterator<float> i(list);
62 i.toBack();
63 while (i.hasPrevious())
64  float f = i.previous();
66 
69 ...
70 QSetIterator<QString> i(set);
71 while (i.hasNext())
72  float f = i.next();
74 
75 
77 QSetIterator<QString> i(set);
78 i.toBack();
79 while (i.hasPrevious())
80  QString s = i.previous();
82 
83 
86 ...
87 QMutableListIterator<float> i(list);
88 while (i.hasNext())
89  float f = i.next();
91 
92 
94 QMutableListIterator<float> i(list);
95 i.toBack();
96 while (i.hasPrevious())
97  float f = i.previous();
99 
100 
102 QMutableListIterator<int> i(list);
103 while (i.hasNext()) {
104  int val = i.next();
105  if (val < 0) {
106  i.setValue(-val);
107  } else if (val == 0) {
108  i.remove();
109  }
110 }
112 
115 ...
116 QMutableSetIterator<float> i(set);
117 while (i.hasNext())
118  float f = i.next();
120 
122 QMutableListIterator<int> i(list);
123 while (i.hasNext()) {
124  int val = i.next();
125  if (val < -32768 || val > 32767)
126  i.remove();
127 }
129 
132 while (i.hasNext()) {
133  int val = i.next();
134  if (val < -32768 || val > 32767)
135  i.remove();
136 }
138 
139 
141 QMutableListIterator<double> i(list);
142 while (i.hasNext()) {
143  double val = i.next();
144  i.setValue(std::sqrt(val));
145 }
147 
150 ...
151 QMapIterator<int, QWidget *> i(map);
152 while (i.hasNext()) {
153  i.next();
154  qDebug() << i.key() << ": " << i.value();
155 }
157 
158 
160 QMapIterator<int, QWidget *> i(map);
161 i.toBack();
162 while (i.hasPrevious()) {
163  i.previous();
164  qDebug() << i.key() << ": " << i.value();
165 }
167 
168 
170 QMapIterator<int, QWidget *> i(map);
171 while (i.findNext(widget)) {
172  qDebug() << "Found widget " << widget << " under key "
173  << i.key();
174 }
176 
179 ...
180 QMultiMapIterator<int, QWidget *> i(multimap);
181 while (i.hasNext()) {
182  i.next();
183  qDebug() << i.key() << ": " << i.value();
184 }
186 
187 
189 QMultiMapIterator<int, QWidget *> i(multimap);
190 i.toBack();
191 while (i.hasPrevious()) {
192  i.previous();
193  qDebug() << i.key() << ": " << i.value();
194 }
196 
197 
199 QMultiMapIterator<int, QWidget *> i(multimap);
200 while (i.findNext(widget)) {
201  qDebug() << "Found widget " << widget << " under key "
202  << i.key();
203 }
205 
206 
209 ...
210 QHashIterator<int, QWidget *> i(hash);
211 while (i.hasNext()) {
212  i.next();
213  qDebug() << i.key() << ": " << i.value();
214 }
216 
217 
219 QHashIterator<int, QWidget *> i(hash);
220 while (i.findNext(widget)) {
221  qDebug() << "Found widget " << widget << " under key "
222  << i.key();
223 }
225 
226 
229 ...
230 QMutableMapIterator<int, QWidget *> i(map);
231 while (i.hasNext()) {
232  i.next();
233  qDebug() << i.key() << ": " << i.value();
234 }
236 
237 
239 QMutableMapIterator<int, QWidget *> i(map);
240 i.toBack();
241 while (i.hasPrevious()) {
242  i.previous();
243  qDebug() << i.key() << ": " << i.value();
244 }
246 
247 
249 QMutableMapIterator<int, QWidget *> i(map);
250 while (i.findNext(widget)) {
251  qDebug() << "Found widget " << widget << " under key "
252  << i.key();
253 }
255 
256 
258 QMutableMapIterator<QString, QString> i(map);
259 while (i.hasNext()) {
260  i.next();
261  if (i.key() == i.value())
262  i.remove();
263 }
265 
266 
269 ...
270 QMutableMultiMapIterator<int, QWidget *> i(multimap);
271 while (i.hasNext()) {
272  i.next();
273  qDebug() << i.key() << ": " << i.value();
274 }
276 
277 
279 QMutableMultiMapIterator<int, QWidget *> i(multimap);
280 i.toBack();
281 while (i.hasPrevious()) {
282  i.previous();
283  qDebug() << i.key() << ": " << i.value();
284 }
286 
287 
289 QMutableMultiMapIterator<int, QWidget *> i(multimap);
290 while (i.findNext(widget)) {
291  qDebug() << "Found widget " << widget << " under key "
292  << i.key();
293 }
295 
296 
298 QMutableMultiMapIterator<QString, QString> i(multimap);
299 while (i.hasNext()) {
300  i.next();
301  if (i.key() == i.value())
302  i.remove();
303 }
305 
306 
309 ...
310 QMutableHashIterator<QString, QWidget *> i(hash);
311 while (i.hasNext()) {
312  i.next();
313  qDebug() << i.key() << ": " << i.value();
314 }
316 
317 
319 QMutableHashIterator<int, QWidget *> i(hash);
320 while (i.findNext(widget)) {
321  qDebug() << "Found widget " << widget << " under key "
322  << i.key();
323 }
325 
326 
328 QMutableHashIterator<QString, QString> i(hash);
329 while (i.hasNext()) {
330  i.next();
331  if (i.key() == i.value())
332  i.remove();
333 }
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qhash.h:773
Definition: qmap.h:222
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
QOpenGLWidget * widget
[1]
QSet< QString > set
[1]
QMap< int, QWidget * > map
[23]
QList< float > list
[0]
QHash< int, QWidget * > hash
[28multi]
QMultiMap< int, QWidget * > multimap
[28]
QMutableSetIterator< float > i(set)
[19]
#define QString()
Definition: parse-defines.h:51
#define qDebug
[1]
Definition: qlogging.h:177
GLfloat GLfloat f
GLuint GLfloat * val
Definition: qopenglext.h:1513
GLdouble s
[6]
Definition: qopenglext.h:235