Warning: That file was not part of the compilation database. It may have many parsing errors.
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:FDL$ |
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 | ** GNU Free Documentation License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Free |
19 | ** Documentation License version 1.3 as published by the Free Software |
20 | ** Foundation and appearing in the file included in the packaging of |
21 | ** this file. Please review the following information to ensure |
22 | ** the GNU Free Documentation License version 1.3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/fdl-1.3.html. |
24 | ** $QT_END_LICENSE$ |
25 | ** |
26 | ****************************************************************************/ |
27 | |
28 | /*! \class QKeyValueIterator |
29 | \inmodule QtCore |
30 | \since 5.10 |
31 | |
32 | \brief Iterator over the key/value pairs of an associative container. |
33 | |
34 | The QKeyValueIterator class provides an STL-style iterator for returning |
35 | key/value pairs from associative containers like QHash and QMap. It |
36 | supports the same API as the STL associative containers, i.e. getting a |
37 | key/value pair when iterating through the container. |
38 | |
39 | This will allow for better interoperability between QMap, QHash and friends |
40 | and STL-style algorithms. |
41 | |
42 | \warning Iterators on implicitly shared containers do not work |
43 | exactly like STL-iterators. You should avoid copying a container |
44 | while iterators are active on that container. For more information, |
45 | read \l{Implicit sharing iterator problem}. |
46 | */ |
47 | |
48 | /*! \typedef QKeyValueIterator::iterator_category |
49 | \internal |
50 | */ |
51 | |
52 | /*! \typedef QKeyValueIterator::difference_type |
53 | \internal |
54 | */ |
55 | |
56 | /*! \typedef QKeyValueIterator::value_type |
57 | \internal |
58 | */ |
59 | |
60 | /*! \typedef QKeyValueIterator::pointer |
61 | \internal |
62 | */ |
63 | |
64 | /*! \typedef QKeyValueIterator::reference |
65 | \internal |
66 | */ |
67 | |
68 | /*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator<Key, T, Iterator>::QKeyValueIterator() |
69 | |
70 | Constructs a default QKeyValueIterator. |
71 | */ |
72 | |
73 | /*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator<Key, T, Iterator>::QKeyValueIterator(Iterator o) |
74 | |
75 | Constructs a QKeyValueIterator on top of \a o. |
76 | */ |
77 | |
78 | /*! \fn template<typename Key, typename T, class Iterator> const T &QKeyValueIterator<Key, T, Iterator>::operator*() const |
79 | |
80 | Returns the current entry as a pair. |
81 | */ |
82 | |
83 | /*! \fn template<typename Key, typename T, class Iterator> bool operator==(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs) |
84 | \relates QKeyValueIterator |
85 | |
86 | Returns \c true if \a rhs points to the same item as \a lhs otherwise returns |
87 | \c false. |
88 | |
89 | \sa operator!=() |
90 | */ |
91 | |
92 | /*! \fn template<typename Key, typename T, class Iterator> bool operator!=(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs) const |
93 | \relates QKeyValueIterator |
94 | |
95 | Returns \c true if \a rhs points to a different item than \a lhs otherwise |
96 | returns \c false. |
97 | |
98 | \sa operator==() |
99 | */ |
100 | |
101 | /*! |
102 | \fn template<typename Key, typename T, class Iterator> QKeyValueIterator &QKeyValueIterator<Key, T, Iterator>::operator++() |
103 | |
104 | The prefix ++ operator (\c{++i}) advances the iterator to the |
105 | next item in the container and returns the iterator. |
106 | |
107 | \note Advancing the iterator past its container's end() constitutes |
108 | undefined behavior. |
109 | |
110 | \sa operator--() |
111 | */ |
112 | |
113 | /*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator QKeyValueIterator<Key, T, Iterator>::operator++(int) |
114 | |
115 | \overload |
116 | |
117 | The postfix ++ operator (\c{i++}) advances the iterator to the |
118 | next item in the container and returns the iterator's prior value. |
119 | |
120 | \note Advancing the iterator past its container's end() constitutes |
121 | undefined behavior. |
122 | */ |
123 | |
124 | /*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator &QKeyValueIterator<Key, T, Iterator>::operator--() |
125 | |
126 | The prefix -- operator (\c{--i}) backs the iterator up to the previous item |
127 | in the container and returns the iterator. |
128 | |
129 | \note Backing up an iterator to before its container's begin() constitutes |
130 | undefined behavior. |
131 | |
132 | \sa operator++() |
133 | */ |
134 | |
135 | /*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator QKeyValueIterator<Key, T, Iterator>::operator--(int) |
136 | |
137 | \overload |
138 | |
139 | The postfix -- operator (\c{i--}) backs the iterator up to the previous item |
140 | in the container and returns the iterator's prior value. |
141 | |
142 | \note Backing up an iterator to before its container's begin() constitutes |
143 | undefined behavior. |
144 | */ |
145 | |
146 | /*! \fn template<typename Key, typename T, class Iterator> Iterator QKeyValueIterator<Key, T, Iterator>::base() const |
147 | Returns the underlying iterator this QKeyValueIterator is based on. |
148 | */ |
149 | |
150 | /*! |
151 | \class QListIterator |
152 | \inmodule QtCore |
153 | |
154 | \brief The QListIterator class provides a Java-style const iterator for QList and QQueue. |
155 | |
156 | QList has both \l{Java-style iterators} and \l{STL-style |
157 | iterators}. The Java-style iterators are more high-level and |
158 | easier to use than the STL-style iterators; on the other hand, |
159 | they are slightly less efficient. |
160 | |
161 | An alternative to using iterators is to use index positions. Most |
162 | QList member functions take an index as their first parameter, |
163 | making it possible to access, modify, and remove items without |
164 | using iterators. |
165 | |
166 | QListIterator\<T\> allows you to iterate over a QList\<T\> (or a |
167 | QQueue\<T\>). If you want to modify the list as you iterate over |
168 | it, use QMutableListIterator\<T\> instead. |
169 | |
170 | The QListIterator constructor takes a QList as argument. After |
171 | construction, the iterator is located at the very beginning of |
172 | the list (before the first item). Here's how to iterate over all |
173 | the elements sequentially: |
174 | |
175 | \snippet code/doc_src_qiterator.cpp 0 |
176 | |
177 | The next() function returns the next item in the list and |
178 | advances the iterator. Unlike STL-style iterators, Java-style |
179 | iterators point \e between items rather than directly \e at |
180 | items. The first call to next() advances the iterator to the |
181 | position between the first and second item, and returns the first |
182 | item; the second call to next() advances the iterator to the |
183 | position between the second and third item, and returns the second |
184 | item; and so on. |
185 | |
186 | \image javaiterators1.png |
187 | |
188 | Here's how to iterate over the elements in reverse order: |
189 | |
190 | \snippet code/doc_src_qiterator.cpp 1 |
191 | |
192 | If you want to find all occurrences of a particular value, use |
193 | findNext() or findPrevious() in a loop. |
194 | |
195 | Multiple iterators can be used on the same list. If the list is |
196 | modified while a QListIterator is active, the QListIterator will |
197 | continue iterating over the original list, ignoring the modified |
198 | copy. |
199 | |
200 | \sa QMutableListIterator, QList::const_iterator |
201 | */ |
202 | |
203 | /*! |
204 | \class QLinkedListIterator |
205 | \inmodule QtCore |
206 | |
207 | \brief The QLinkedListIterator class provides a Java-style const iterator for QLinkedList. |
208 | |
209 | QLinkedList has both \l{Java-style iterators} and |
210 | \l{STL-style iterators}. The Java-style iterators are more |
211 | high-level and easier to use than the STL-style iterators; on the |
212 | other hand, they are slightly less efficient. |
213 | |
214 | QLinkedListIterator\<T\> allows you to iterate over a |
215 | QLinkedList\<T\>. If you want to modify the list as you iterate |
216 | over it, use QMutableLinkedListIterator\<T\> instead. |
217 | |
218 | The QLinkedListIterator constructor takes a QLinkedList as |
219 | argument. After construction, the iterator is located at the very |
220 | beginning of the list (before the first item). Here's how to |
221 | iterate over all the elements sequentially: |
222 | |
223 | \snippet code/doc_src_qiterator.cpp 2 |
224 | |
225 | The next() function returns the next item in the list and |
226 | advances the iterator. Unlike STL-style iterators, Java-style |
227 | iterators point \e between items rather than directly \e at |
228 | items. The first call to next() advances the iterator to the |
229 | position between the first and second item, and returns the first |
230 | item; the second call to next() advances the iterator to the |
231 | position between the second and third item, and returns the second |
232 | item; and so on. |
233 | |
234 | \image javaiterators1.png |
235 | |
236 | Here's how to iterate over the elements in reverse order: |
237 | |
238 | \snippet code/doc_src_qiterator.cpp 3 |
239 | |
240 | If you want to find all occurrences of a particular value, use |
241 | findNext() or findPrevious() in a loop. |
242 | |
243 | Multiple iterators can be used on the same list. If the list is |
244 | modified while a QLinkedListIterator is active, the |
245 | QLinkedListIterator will continue iterating over the original |
246 | list, ignoring the modified copy. |
247 | |
248 | \sa QMutableLinkedListIterator, QLinkedList::const_iterator |
249 | */ |
250 | |
251 | /*! |
252 | \class QVectorIterator |
253 | \inmodule QtCore |
254 | \brief The QVectorIterator class provides a Java-style const iterator for QVector and QStack. |
255 | |
256 | QVector has both \l{Java-style iterators} and \l{STL-style |
257 | iterators}. The Java-style iterators are more high-level and |
258 | easier to use than the STL-style iterators; on the other hand, |
259 | they are slightly less efficient. |
260 | |
261 | An alternative to using iterators is to use index positions. Most |
262 | QVector member functions take an index as their first parameter, |
263 | making it possible to access, insert, and remove items without |
264 | using iterators. |
265 | |
266 | QVectorIterator\<T\> allows you to iterate over a QVector\<T\> |
267 | (or a QStack\<T\>). If you want to modify the vector as you |
268 | iterate over it, use QMutableVectorIterator\<T\> instead. |
269 | |
270 | The QVectorIterator constructor takes a QVector as argument. |
271 | After construction, the iterator is located at the very beginning |
272 | of the vector (before the first item). Here's how to iterate over |
273 | all the elements sequentially: |
274 | |
275 | \snippet code/doc_src_qiterator.cpp 4 |
276 | |
277 | The next() function returns the next item in the vector and |
278 | advances the iterator. Unlike STL-style iterators, Java-style |
279 | iterators point \e between items rather than directly \e at |
280 | items. The first call to next() advances the iterator to the |
281 | position between the first and second item, and returns the first |
282 | item; the second call to next() advances the iterator to the |
283 | position between the second and third item, returning the second |
284 | item; and so on. |
285 | |
286 | \image javaiterators1.png |
287 | |
288 | Here's how to iterate over the elements in reverse order: |
289 | |
290 | \snippet code/doc_src_qiterator.cpp 5 |
291 | |
292 | If you want to find all occurrences of a particular value, use |
293 | findNext() or findPrevious() in a loop. |
294 | |
295 | Multiple iterators can be used on the same vector. If the vector |
296 | is modified while a QVectorIterator is active, the QVectorIterator |
297 | will continue iterating over the original vector, ignoring the |
298 | modified copy. |
299 | |
300 | \sa QMutableVectorIterator, QVector::const_iterator |
301 | */ |
302 | |
303 | /*! |
304 | \class QSetIterator |
305 | \inmodule QtCore |
306 | \brief The QSetIterator class provides a Java-style const iterator for QSet. |
307 | |
308 | QSet supports both \l{Java-style iterators} and \l{STL-style |
309 | iterators}. The Java-style iterators are more high-level and |
310 | easier to use than the STL-style iterators; on the other hand, |
311 | they are slightly less efficient. |
312 | |
313 | QSetIterator\<T\> allows you to iterate over a QSet\<T\>. If you |
314 | want to modify the set as you iterate over it, use |
315 | QMutableSetIterator\<T\> instead. |
316 | |
317 | The constructor takes a QSet as argument. After construction, the |
318 | iterator is located at the very beginning of the set (before |
319 | the first item). Here's how to iterate over all the elements |
320 | sequentially: |
321 | |
322 | \snippet code/doc_src_qiterator.cpp 6 |
323 | |
324 | The next() function returns the next item in the set and |
325 | advances the iterator. Unlike STL-style iterators, Java-style |
326 | iterators point \e between items rather than directly \e at |
327 | items. The first call to next() advances the iterator to the |
328 | position between the first and second item, and returns the first |
329 | item; the second call to next() advances the iterator to the |
330 | position between the second and third item, returning the second |
331 | item; and so on. |
332 | |
333 | \image javaiterators1.png |
334 | |
335 | Here's how to iterate over the elements in reverse order: |
336 | |
337 | \snippet code/doc_src_qiterator.cpp 7 |
338 | |
339 | If you want to find all occurrences of a particular value, use |
340 | findNext() or findPrevious() in a loop. |
341 | |
342 | Multiple iterators can be used on the same set. If the set |
343 | is modified while a QSetIterator is active, the QSetIterator |
344 | will continue iterating over the original set, ignoring the |
345 | modified copy. |
346 | |
347 | \sa QMutableSetIterator, QSet::const_iterator |
348 | */ |
349 | |
350 | /*! |
351 | \class QMutableListIterator |
352 | \inmodule QtCore |
353 | |
354 | \brief The QMutableListIterator class provides a Java-style non-const iterator for QList and QQueue. |
355 | |
356 | QList has both \l{Java-style iterators} and \l{STL-style |
357 | iterators}. The Java-style iterators are more high-level and |
358 | easier to use than the STL-style iterators; on the other hand, |
359 | they are slightly less efficient. |
360 | |
361 | An alternative to using iterators is to use index positions. Most |
362 | QList member functions take an index as their first parameter, |
363 | making it possible to access, insert, and remove items without |
364 | using iterators. |
365 | |
366 | QMutableListIterator\<T\> allows you to iterate over a QList\<T\> |
367 | (or a QQueue\<T\>) and modify the list. If you don't want to |
368 | modify the list (or have a const QList), use the slightly faster |
369 | QListIterator\<T\> instead. |
370 | |
371 | The QMutableListIterator constructor takes a QList as argument. |
372 | After construction, the iterator is located at the very beginning |
373 | of the list (before the first item). Here's how to iterate over |
374 | all the elements sequentially: |
375 | |
376 | \snippet code/doc_src_qiterator.cpp 8 |
377 | |
378 | The next() function returns the next item in the list and |
379 | advances the iterator. Unlike STL-style iterators, Java-style |
380 | iterators point \e between items rather than directly \e at |
381 | items. The first call to next() advances the iterator to the |
382 | position between the first and second item, and returns the first |
383 | item; the second call to next() advances the iterator to the |
384 | position between the second and third item, returning the second |
385 | item; and so on. |
386 | |
387 | \image javaiterators1.png |
388 | |
389 | Here's how to iterate over the elements in reverse order: |
390 | |
391 | \snippet code/doc_src_qiterator.cpp 9 |
392 | |
393 | If you want to find all occurrences of a particular value, use |
394 | findNext() or findPrevious() in a loop. |
395 | |
396 | If you want to remove items as you iterate over the list, use |
397 | remove(). If you want to modify the value of an item, use |
398 | setValue(). If you want to insert a new item in the list, use |
399 | insert(). |
400 | |
401 | Example: |
402 | \snippet code/doc_src_qiterator.cpp 10 |
403 | |
404 | The example traverses a list, replacing negative numbers with |
405 | their absolute values, and eliminating zeroes. |
406 | |
407 | Only one mutable iterator can be active on a given list at any |
408 | time. Furthermore, no changes should be done directly to the list |
409 | while the iterator is active (as opposed to through the |
410 | iterator), since this could invalidate the iterator and lead to |
411 | undefined behavior. |
412 | |
413 | \sa QListIterator, QList::iterator |
414 | */ |
415 | |
416 | /*! |
417 | \class QMutableLinkedListIterator |
418 | \inmodule QtCore |
419 | |
420 | \brief The QMutableLinkedListIterator class provides a Java-style non-const iterator for QLinkedList. |
421 | |
422 | QLinkedList has both \l{Java-style iterators} and |
423 | \l{STL-style iterators}. The Java-style iterators are more |
424 | high-level and easier to use than the STL-style iterators; on the |
425 | other hand, they are slightly less efficient. |
426 | |
427 | QMutableLinkedListIterator\<T\> allows you to iterate over a |
428 | QLinkedList\<T\> and modify the list. If you don't want to modify |
429 | the list (or have a const QLinkedList), use the slightly faster |
430 | QLinkedListIterator\<T\> instead. |
431 | |
432 | The QMutableLinkedListIterator constructor takes a QLinkedList as |
433 | argument. After construction, the iterator is located at the very |
434 | beginning of the list (before the first item). Here's how to |
435 | iterate over all the elements sequentially: |
436 | |
437 | \snippet code/doc_src_qiterator.cpp 11 |
438 | |
439 | The next() function returns the next item in the list and |
440 | advances the iterator. Unlike STL-style iterators, Java-style |
441 | iterators point \e between items rather than directly \e at |
442 | items. The first call to next() advances the iterator to the |
443 | position between the first and second item, and returns the first |
444 | item; the second call to next() advances the iterator to the |
445 | position between the second and third item, returning the second |
446 | item; and so on. |
447 | |
448 | \image javaiterators1.png |
449 | |
450 | Here's how to iterate over the elements in reverse order: |
451 | |
452 | \snippet code/doc_src_qiterator.cpp 12 |
453 | |
454 | If you want to find all occurrences of a particular value, use |
455 | findNext() or findPrevious() in a loop. |
456 | |
457 | If you want to remove items as you iterate over the list, use |
458 | remove(). If you want to modify the value of an item, use |
459 | setValue(). If you want to insert a new item in the list, use |
460 | insert(). |
461 | |
462 | Example: |
463 | \snippet code/doc_src_qiterator.cpp 13 |
464 | |
465 | The example traverses a list, replacing negative numbers with |
466 | their absolute values, and eliminating zeroes. |
467 | |
468 | Only one mutable iterator can be active on a given list at any |
469 | time. Furthermore, no changes should be done directly to the list |
470 | while the iterator is active (as opposed to through the |
471 | iterator), since this could invalidate the iterator and lead to |
472 | undefined behavior. |
473 | |
474 | \sa QLinkedListIterator, QLinkedList::iterator |
475 | */ |
476 | |
477 | /*! |
478 | \class QMutableVectorIterator |
479 | \inmodule QtCore |
480 | |
481 | \brief The QMutableVectorIterator class provides a Java-style non-const iterator for QVector and QStack. |
482 | |
483 | QVector has both \l{Java-style iterators} and \l{STL-style |
484 | iterators}. The Java-style iterators are more high-level and |
485 | easier to use than the STL-style iterators; on the other hand, |
486 | they are slightly less efficient. |
487 | |
488 | An alternative to using iterators is to use index positions. Most |
489 | QVector member functions take an index as their first parameter, |
490 | making it possible to access, insert, and remove items without |
491 | using iterators. |
492 | |
493 | QMutableVectorIterator\<T\> allows you to iterate over a |
494 | QVector\<T\> and modify the vector. If you don't want to modify |
495 | the vector (or have a const QVector), use the slightly faster |
496 | QVectorIterator\<T\> instead. |
497 | |
498 | The QMutableVectorIterator constructor takes a QVector as |
499 | argument. After construction, the iterator is located at the very |
500 | beginning of the list (before the first item). Here's how to |
501 | iterate over all the elements sequentially: |
502 | |
503 | \snippet code/doc_src_qiterator.cpp 14 |
504 | |
505 | The next() function returns the next item in the vector and |
506 | advances the iterator. Unlike STL-style iterators, Java-style |
507 | iterators point \e between items rather than directly \e at |
508 | items. The first call to next() advances the iterator to the |
509 | position between the first and second item, and returns the first |
510 | item; the second call to next() advances the iterator to the |
511 | position between the second and third item, returning the second |
512 | item; and so on. |
513 | |
514 | \image javaiterators1.png |
515 | |
516 | Here's how to iterate over the elements in reverse order: |
517 | |
518 | \snippet code/doc_src_qiterator.cpp 15 |
519 | |
520 | If you want to find all occurrences of a particular value, use |
521 | findNext() or findPrevious() in a loop. |
522 | |
523 | If you want to remove items as you iterate over the vector, use |
524 | remove(). If you want to modify the value of an item, use |
525 | setValue(). If you want to insert a new item in the vector, use |
526 | insert(). |
527 | |
528 | Example: |
529 | \snippet code/doc_src_qiterator.cpp 16 |
530 | |
531 | The example traverses a vector, replacing negative numbers with |
532 | their absolute values, and eliminating zeroes. |
533 | |
534 | Only one mutable iterator can be active on a given vector at any |
535 | time. Furthermore, no changes should be done directly to the |
536 | vector while the iterator is active (as opposed to through the |
537 | iterator), since this could invalidate the iterator and lead to |
538 | undefined behavior. |
539 | |
540 | \sa QVectorIterator, QVector::iterator |
541 | */ |
542 | |
543 | /*! |
544 | \class QMutableSetIterator |
545 | \inmodule QtCore |
546 | \since 4.2 |
547 | |
548 | \brief The QMutableSetIterator class provides a Java-style non-const iterator for QSet. |
549 | |
550 | QSet has both \l{Java-style iterators} and \l{STL-style |
551 | iterators}. The Java-style iterators are more high-level and |
552 | easier to use than the STL-style iterators; on the other hand, |
553 | they are slightly less efficient. |
554 | |
555 | QMutableSetIterator\<T\> allows you to iterate over a QSet\<T\> |
556 | and remove items from the set as you iterate. If you don't want |
557 | to modify the set (or have a const QSet), use the slightly faster |
558 | QSetIterator\<T\> instead. |
559 | |
560 | The QMutableSetIterator constructor takes a QSet as argument. |
561 | After construction, the iterator is located at the very beginning |
562 | of the set (before the first item). Here's how to iterate over |
563 | all the elements sequentially: |
564 | |
565 | \snippet code/doc_src_qiterator.cpp 17 |
566 | |
567 | The next() function returns the next item in the set and |
568 | advances the iterator. Unlike STL-style iterators, Java-style |
569 | iterators point \e between items rather than directly \e at |
570 | items. The first call to next() advances the iterator to the |
571 | position between the first and second item, and returns the first |
572 | item; the second call to next() advances the iterator to the |
573 | position between the second and third item, returning the second |
574 | item; and so on. |
575 | |
576 | \image javaiterators1.png |
577 | |
578 | Here's how to iterate over the elements in reverse order: |
579 | |
580 | \snippet code/doc_src_qiterator.cpp 18 |
581 | |
582 | If you want to remove items as you iterate over the set, use |
583 | remove(). |
584 | |
585 | Only one mutable iterator can be active on a given set at any |
586 | time. Furthermore, no changes should be done directly to the set |
587 | while the iterator is active (as opposed to through the |
588 | iterator), since this could invalidate the iterator and lead to |
589 | undefined behavior. |
590 | |
591 | \sa QSetIterator, QSet::iterator |
592 | */ |
593 | |
594 | /*! |
595 | \fn template <class T> QListIterator<T>::QListIterator(const QList<T> &list) |
596 | \fn template <class T> QLinkedListIterator<T>::QLinkedListIterator(const QLinkedList<T> &list) |
597 | \fn template <class T> QMutableListIterator<T>::QMutableListIterator(QList<T> &list) |
598 | \fn template <class T> QMutableLinkedListIterator<T>::QMutableLinkedListIterator(QLinkedList<T> &list) |
599 | |
600 | Constructs an iterator for traversing \a list. The iterator is |
601 | set to be at the front of the list (before the first item). |
602 | |
603 | \sa operator=() |
604 | */ |
605 | |
606 | /*! |
607 | \fn template <class T> QVectorIterator<T>::QVectorIterator(const QVector<T> &vector) |
608 | \fn template <class T> QMutableVectorIterator<T>::QMutableVectorIterator(QVector<T> &vector) |
609 | |
610 | Constructs an iterator for traversing \a vector. The iterator is |
611 | set to be at the front of the vector (before the first item). |
612 | |
613 | \sa operator=() |
614 | */ |
615 | |
616 | /*! |
617 | \fn template <class T> QSetIterator<T>::QSetIterator(const QSet<T> &set) |
618 | \fn template <class T> QMutableSetIterator<T>::QMutableSetIterator(QSet<T> &set) |
619 | |
620 | Constructs an iterator for traversing \a set. The iterator is |
621 | set to be at the front of the set (before the first item). |
622 | |
623 | \sa operator=() |
624 | */ |
625 | |
626 | /*! \fn template <class T> QMutableListIterator &QMutableListIterator<T>::operator=(QList<T> &list) |
627 | \fn template <class T> QMutableLinkedListIterator &QMutableLinkedListIterator<T>::operator=(QLinkedList<T> &list) |
628 | \fn template <class T> QListIterator &QListIterator<T>::operator=(const QList<T> &list) |
629 | \fn template <class T> QLinkedListIterator &QLinkedListIterator<T>::operator=(const QLinkedList<T> &list) |
630 | |
631 | Makes the iterator operate on \a list. The iterator is set to be |
632 | at the front of the list (before the first item). |
633 | |
634 | \sa toFront(), toBack() |
635 | */ |
636 | |
637 | /*! \fn template <class T> QVectorIterator &QVectorIterator<T>::operator=(const QVector<T> &vector) |
638 | \fn template <class T> QMutableVectorIterator &QMutableVectorIterator<T>::operator=(QVector<T> &vector) |
639 | |
640 | Makes the iterator operate on \a vector. The iterator is set to be |
641 | at the front of the vector (before the first item). |
642 | |
643 | \sa toFront(), toBack() |
644 | */ |
645 | |
646 | /*! \fn template <class T> QSetIterator &QSetIterator<T>::operator=(const QSet<T> &set) |
647 | \fn template <class T> QMutableSetIterator &QMutableSetIterator<T>::operator=(QSet<T> &set) |
648 | |
649 | Makes the iterator operate on \a set. The iterator is set to be |
650 | at the front of the set (before the first item). |
651 | |
652 | \sa toFront(), toBack() |
653 | */ |
654 | |
655 | /*! \fn template <class T> void QListIterator<T>::toFront() |
656 | \fn template <class T> void QLinkedListIterator<T>::toFront() |
657 | \fn template <class T> void QVectorIterator<T>::toFront() |
658 | \fn template <class T> void QSetIterator<T>::toFront() |
659 | \fn template <class T> void QMutableListIterator<T>::toFront() |
660 | \fn template <class T> void QMutableLinkedListIterator<T>::toFront() |
661 | \fn template <class T> void QMutableVectorIterator<T>::toFront() |
662 | \fn template <class T> void QMutableSetIterator<T>::toFront() |
663 | |
664 | Moves the iterator to the front of the container (before the |
665 | first item). |
666 | |
667 | \sa toBack(), next() |
668 | */ |
669 | |
670 | /*! \fn template <class T> void QListIterator<T>::toBack() |
671 | \fn template <class T> void QLinkedListIterator<T>::toBack() |
672 | \fn template <class T> void QVectorIterator<T>::toBack() |
673 | \fn template <class T> void QSetIterator<T>::toBack() |
674 | \fn template <class T> void QMutableListIterator<T>::toBack() |
675 | \fn template <class T> void QMutableLinkedListIterator<T>::toBack() |
676 | \fn template <class T> void QMutableVectorIterator<T>::toBack() |
677 | \fn template <class T> void QMutableSetIterator<T>::toBack() |
678 | |
679 | Moves the iterator to the back of the container (after the last |
680 | item). |
681 | |
682 | \sa toFront(), previous() |
683 | */ |
684 | |
685 | /*! \fn template <class T> bool QListIterator<T>::hasNext() const |
686 | \fn template <class T> bool QLinkedListIterator<T>::hasNext() const |
687 | \fn template <class T> bool QVectorIterator<T>::hasNext() const |
688 | \fn template <class T> bool QSetIterator<T>::hasNext() const |
689 | \fn template <class T> bool QMutableListIterator<T>::hasNext() const |
690 | \fn template <class T> bool QMutableLinkedListIterator<T>::hasNext() const |
691 | \fn template <class T> bool QMutableVectorIterator<T>::hasNext() const |
692 | \fn template <class T> bool QMutableSetIterator<T>::hasNext() const |
693 | |
694 | Returns \c true if there is at least one item ahead of the iterator, |
695 | i.e. the iterator is \e not at the back of the container; |
696 | otherwise returns \c false. |
697 | |
698 | \sa hasPrevious(), next() |
699 | */ |
700 | |
701 | /*! \fn template <class T> const T &QListIterator<T>::next() |
702 | \fn template <class T> const T &QLinkedListIterator<T>::next() |
703 | \fn template <class T> const T &QVectorIterator<T>::next() |
704 | \fn template <class T> const T &QSetIterator<T>::next() |
705 | \fn template <class T> const T &QMutableSetIterator<T>::next() |
706 | |
707 | Returns the next item and advances the iterator by one position. |
708 | |
709 | Calling this function on an iterator located at the back of the |
710 | container leads to undefined results. |
711 | |
712 | \sa hasNext(), peekNext(), previous() |
713 | */ |
714 | |
715 | /*! \fn template <class T> T &QMutableListIterator<T>::next() |
716 | \fn template <class T> T &QMutableLinkedListIterator<T>::next() |
717 | \fn template <class T> T &QMutableVectorIterator<T>::next() |
718 | |
719 | Returns a reference to the next item, and advances the iterator |
720 | by one position. |
721 | |
722 | Calling this function on an iterator located at the back of the |
723 | container leads to undefined results. |
724 | |
725 | \sa hasNext(), peekNext(), previous() |
726 | */ |
727 | |
728 | /*! \fn template <class T> const T &QListIterator<T>::peekNext() const |
729 | \fn template <class T> const T &QLinkedListIterator<T>::peekNext() const |
730 | \fn template <class T> const T &QVectorIterator<T>::peekNext() const |
731 | \fn template <class T> const T &QSetIterator<T>::peekNext() const |
732 | \fn template <class T> const T &QMutableSetIterator<T>::peekNext() const |
733 | |
734 | Returns the next item without moving the iterator. |
735 | |
736 | Calling this function on an iterator located at the back of the |
737 | container leads to undefined results. |
738 | |
739 | \sa hasNext(), next(), peekPrevious() |
740 | */ |
741 | |
742 | /*! \fn template <class T> T &QMutableListIterator<T>::peekNext() const |
743 | \fn template <class T> T &QMutableLinkedListIterator<T>::peekNext() const |
744 | \fn template <class T> T &QMutableVectorIterator<T>::peekNext() const |
745 | |
746 | Returns a reference to the next item, without moving the iterator. |
747 | |
748 | Calling this function on an iterator located at the back of the |
749 | container leads to undefined results. |
750 | |
751 | \sa hasNext(), next(), peekPrevious() |
752 | */ |
753 | |
754 | /*! \fn template <class T> bool QListIterator<T>::hasPrevious() const |
755 | \fn template <class T> bool QLinkedListIterator<T>::hasPrevious() const |
756 | \fn template <class T> bool QVectorIterator<T>::hasPrevious() const |
757 | \fn template <class T> bool QSetIterator<T>::hasPrevious() const |
758 | \fn template <class T> bool QMutableListIterator<T>::hasPrevious() const |
759 | \fn template <class T> bool QMutableLinkedListIterator<T>::hasPrevious() const |
760 | \fn template <class T> bool QMutableVectorIterator<T>::hasPrevious() const |
761 | \fn template <class T> bool QMutableSetIterator<T>::hasPrevious() const |
762 | |
763 | Returns \c true if there is at least one item behind the iterator, |
764 | i.e. the iterator is \e not at the front of the container; |
765 | otherwise returns \c false. |
766 | |
767 | \sa hasNext(), previous() |
768 | */ |
769 | |
770 | /*! \fn template <class T> const T &QListIterator<T>::previous() |
771 | \fn template <class T> const T &QLinkedListIterator<T>::previous() |
772 | \fn template <class T> const T &QVectorIterator<T>::previous() |
773 | \fn template <class T> const T &QSetIterator<T>::previous() |
774 | \fn template <class T> const T &QMutableSetIterator<T>::previous() |
775 | |
776 | Returns the previous item and moves the iterator back by one |
777 | position. |
778 | |
779 | Calling this function on an iterator located at the front of the |
780 | container leads to undefined results. |
781 | |
782 | \sa hasPrevious(), peekPrevious(), next() |
783 | */ |
784 | |
785 | /*! \fn template <class T> T &QMutableListIterator<T>::previous() |
786 | \fn template <class T> T &QMutableLinkedListIterator<T>::previous() |
787 | \fn template <class T> T &QMutableVectorIterator<T>::previous() |
788 | |
789 | Returns a reference to the previous item and moves the iterator |
790 | back by one position. |
791 | |
792 | Calling this function on an iterator located at the front of the |
793 | container leads to undefined results. |
794 | |
795 | \sa hasPrevious(), peekPrevious(), next() |
796 | */ |
797 | |
798 | /*! \fn template <class T> const T &QListIterator<T>::peekPrevious() const |
799 | \fn template <class T> const T &QLinkedListIterator<T>::peekPrevious() const |
800 | \fn template <class T> const T &QVectorIterator<T>::peekPrevious() const |
801 | \fn template <class T> const T &QSetIterator<T>::peekPrevious() const |
802 | \fn template <class T> const T &QMutableSetIterator<T>::peekPrevious() const |
803 | |
804 | Returns the previous item without moving the iterator. |
805 | |
806 | Calling this function on an iterator located at the front of the |
807 | container leads to undefined results. |
808 | |
809 | \sa hasPrevious(), previous(), peekNext() |
810 | */ |
811 | |
812 | /*! \fn template <class T> T &QMutableListIterator<T>::peekPrevious() const |
813 | \fn template <class T> T &QMutableLinkedListIterator<T>::peekPrevious() const |
814 | \fn template <class T> T &QMutableVectorIterator<T>::peekPrevious() const |
815 | |
816 | Returns a reference to the previous item, without moving the iterator. |
817 | |
818 | Calling this function on an iterator located at the front of the |
819 | container leads to undefined results. |
820 | |
821 | \sa hasPrevious(), previous(), peekNext() |
822 | */ |
823 | |
824 | /*! \fn template <class T> bool QListIterator<T>::findNext(const T &value) |
825 | \fn template <class T> bool QLinkedListIterator<T>::findNext(const T &value) |
826 | \fn template <class T> bool QVectorIterator<T>::findNext(const T &value) |
827 | \fn template <class T> bool QSetIterator<T>::findNext(const T &value) |
828 | \fn template <class T> bool QMutableListIterator<T>::findNext(const T &value) |
829 | \fn template <class T> bool QMutableLinkedListIterator<T>::findNext(const T &value) |
830 | \fn template <class T> bool QMutableVectorIterator<T>::findNext(const T &value) |
831 | \fn template <class T> bool QMutableSetIterator<T>::findNext(const T &value) |
832 | |
833 | Searches for \a value starting from the current iterator position |
834 | forward. Returns \c true if \a value is found; otherwise returns \c false. |
835 | |
836 | After the call, if \a value was found, the iterator is positioned |
837 | just after the matching item; otherwise, the iterator is |
838 | positioned at the back of the container. |
839 | |
840 | \sa findPrevious() |
841 | */ |
842 | |
843 | /*! \fn template <class T> bool QListIterator<T>::findPrevious(const T &value) |
844 | \fn template <class T> bool QLinkedListIterator<T>::findPrevious(const T &value) |
845 | \fn template <class T> bool QVectorIterator<T>::findPrevious(const T &value) |
846 | \fn template <class T> bool QSetIterator<T>::findPrevious(const T &value) |
847 | \fn template <class T> bool QMutableListIterator<T>::findPrevious(const T &value) |
848 | \fn template <class T> bool QMutableLinkedListIterator<T>::findPrevious(const T &value) |
849 | \fn template <class T> bool QMutableVectorIterator<T>::findPrevious(const T &value) |
850 | \fn template <class T> bool QMutableSetIterator<T>::findPrevious(const T &value) |
851 | |
852 | Searches for \a value starting from the current iterator position |
853 | backward. Returns \c true if \a value is found; otherwise returns |
854 | false. |
855 | |
856 | After the call, if \a value was found, the iterator is positioned |
857 | just before the matching item; otherwise, the iterator is |
858 | positioned at the front of the container. |
859 | |
860 | \sa findNext() |
861 | */ |
862 | |
863 | /*! \fn template <class T> void QMutableListIterator<T>::remove() |
864 | |
865 | Removes the last item that was jumped over using one of the |
866 | traversal functions (next(), previous(), findNext(), findPrevious()). |
867 | |
868 | Example: |
869 | \snippet code/doc_src_qiterator.cpp 19 |
870 | |
871 | \sa insert(), setValue() |
872 | */ |
873 | |
874 | /*! \fn template <class T> void QMutableLinkedListIterator<T>::remove() |
875 | |
876 | Removes the last item that was jumped over using one of the |
877 | traversal functions (next(), previous(), findNext(), findPrevious()). |
878 | |
879 | Example: |
880 | \snippet code/doc_src_qiterator.cpp 20 |
881 | |
882 | \sa insert(), setValue() |
883 | */ |
884 | |
885 | /*! \fn template <class T> void QMutableVectorIterator<T>::remove() |
886 | |
887 | Removes the last item that was jumped over using one of the |
888 | traversal functions (next(), previous(), findNext(), findPrevious()). |
889 | |
890 | Example: |
891 | \snippet code/doc_src_qiterator.cpp 21 |
892 | |
893 | \sa insert(), setValue() |
894 | */ |
895 | |
896 | /*! \fn template <class T> void QMutableSetIterator<T>::remove() |
897 | |
898 | Removes the last item that was jumped over using one of the |
899 | traversal functions (next(), previous(), findNext(), findPrevious()). |
900 | |
901 | Example: |
902 | \snippet code/doc_src_qiterator.cpp 22 |
903 | |
904 | \sa value() |
905 | */ |
906 | |
907 | /*! \fn template <class T> void QMutableListIterator<T>::setValue(const T &value) const |
908 | |
909 | Replaces the value of the last item that was jumped over using |
910 | one of the traversal functions with \a value. |
911 | |
912 | The traversal functions are next(), previous(), findNext(), and |
913 | findPrevious(). |
914 | |
915 | Example: |
916 | \snippet code/doc_src_qiterator.cpp 23 |
917 | |
918 | \sa value(), remove(), insert() |
919 | */ |
920 | |
921 | /*! \fn template <class T> void QMutableLinkedListIterator<T>::setValue(const T &value) const |
922 | |
923 | Replaces the value of the last item that was jumped over using |
924 | one of the traversal functions with \a value. |
925 | |
926 | The traversal functions are next(), previous(), findNext(), and |
927 | findPrevious(). |
928 | |
929 | Example: |
930 | \snippet code/doc_src_qiterator.cpp 24 |
931 | |
932 | \sa value(), remove(), insert() |
933 | */ |
934 | |
935 | /*! \fn template <class T> void QMutableVectorIterator<T>::setValue(const T &value) const |
936 | |
937 | Replaces the value of the last item that was jumped over using |
938 | one of the traversal functions with \a value. |
939 | |
940 | The traversal functions are next(), previous(), findNext(), and |
941 | findPrevious(). |
942 | |
943 | Example: |
944 | \snippet code/doc_src_qiterator.cpp 25 |
945 | |
946 | \sa value(), remove(), insert() |
947 | */ |
948 | |
949 | /*! \fn template <class T> const T &QMutableListIterator<T>::value() const |
950 | \fn template <class T> const T &QMutableLinkedListIterator<T>::value() const |
951 | \fn template <class T> const T &QMutableVectorIterator<T>::value() const |
952 | \fn template <class T> const T &QMutableSetIterator<T>::value() const |
953 | |
954 | Returns the value of the last item that was jumped over using one |
955 | of the traversal functions (next(), previous(), findNext(), |
956 | findPrevious()). |
957 | |
958 | After a call to next() or findNext(), value() is equivalent to |
959 | peekPrevious(). After a call to previous() or findPrevious(), value() is |
960 | equivalent to peekNext(). |
961 | */ |
962 | |
963 | /*! |
964 | \fn template <class T> T &QMutableListIterator<T>::value() |
965 | \fn template <class T> T &QMutableLinkedListIterator<T>::value() |
966 | \fn template <class T> T &QMutableVectorIterator<T>::value() |
967 | \overload |
968 | |
969 | Returns a non-const reference to the value of the last item that |
970 | was jumped over using one of the traversal functions. |
971 | */ |
972 | |
973 | /*! \fn template <class T> void QMutableListIterator<T>::insert(const T &value) |
974 | \fn template <class T> void QMutableLinkedListIterator<T>::insert(const T &value) |
975 | \fn template <class T> void QMutableVectorIterator<T>::insert(const T &value) |
976 | |
977 | Inserts \a value at the current iterator position. After the |
978 | call, the iterator is located just after the inserted item. |
979 | |
980 | \sa remove(), setValue() |
981 | */ |
982 | |
983 | /*! |
984 | \class QMapIterator |
985 | \inmodule QtCore |
986 | |
987 | \brief The QMapIterator class provides a Java-style const iterator for QMap and QMultiMap. |
988 | |
989 | QMap has both \l{Java-style iterators} and \l{STL-style |
990 | iterators}. The Java-style iterators are more high-level and |
991 | easier to use than the STL-style iterators; on the other hand, |
992 | they are slightly less efficient. |
993 | |
994 | QMapIterator\<Key, T\> allows you to iterate over a QMap (or a |
995 | QMultiMap). If you want to modify the map as you iterate over |
996 | it, use QMutableMapIterator instead. |
997 | |
998 | The QMapIterator constructor takes a QMap as argument. After |
999 | construction, the iterator is located at the very beginning of |
1000 | the map (before the first item). Here's how to iterate over all |
1001 | the elements sequentially: |
1002 | |
1003 | \snippet code/doc_src_qiterator.cpp 26 |
1004 | |
1005 | The next() function returns the next item in the map and |
1006 | advances the iterator. The key() and value() functions return the |
1007 | key and value of the last item that was jumped over. |
1008 | |
1009 | Unlike STL-style iterators, Java-style iterators point \e between |
1010 | items rather than directly \e at items. The first call to next() |
1011 | advances the iterator to the position between the first and |
1012 | second item, and returns the first item; the second call to |
1013 | next() advances the iterator to the position between the second |
1014 | and third item; and so on. |
1015 | |
1016 | \image javaiterators1.png |
1017 | |
1018 | Here's how to iterate over the elements in reverse order: |
1019 | |
1020 | \snippet code/doc_src_qiterator.cpp 27 |
1021 | |
1022 | If you want to find all occurrences of a particular value, use |
1023 | findNext() or findPrevious() in a loop. For example: |
1024 | |
1025 | \snippet code/doc_src_qiterator.cpp 28 |
1026 | |
1027 | Multiple iterators can be used on the same map. If the map is |
1028 | modified while a QMapIterator is active, the QMapIterator will |
1029 | continue iterating over the original map, ignoring the modified |
1030 | copy. |
1031 | |
1032 | \sa QMutableMapIterator, QMap::const_iterator |
1033 | */ |
1034 | |
1035 | /*! |
1036 | \class QHashIterator |
1037 | \inmodule QtCore |
1038 | |
1039 | \brief The QHashIterator class provides a Java-style const iterator for QHash and QMultiHash. |
1040 | |
1041 | QHash has both \l{Java-style iterators} and \l{STL-style |
1042 | iterators}. The Java-style iterators are more high-level and |
1043 | easier to use than the STL-style iterators; on the other hand, |
1044 | they are slightly less efficient. |
1045 | |
1046 | QHashIterator\<Key, T\> allows you to iterate over a QHash (or a |
1047 | QMultiHash). If you want to modify the hash as you iterate over |
1048 | it, use QMutableHashIterator instead. |
1049 | |
1050 | The QHashIterator constructor takes a QHash as argument. After |
1051 | construction, the iterator is located at the very beginning of |
1052 | the hash (before the first item). Here's how to iterate over all |
1053 | the elements sequentially: |
1054 | |
1055 | \snippet code/doc_src_qiterator.cpp 29 |
1056 | |
1057 | The next() function returns the next item in the hash and |
1058 | advances the iterator. The key() and value() functions return the |
1059 | key and value of the last item that was jumped over. |
1060 | |
1061 | Unlike STL-style iterators, Java-style iterators point \e between |
1062 | items rather than directly \e at items. The first call to next() |
1063 | advances the iterator to the position between the first and |
1064 | second item, and returns the first item; the second call to |
1065 | next() advances the iterator to the position between the second |
1066 | and third item; and so on. |
1067 | |
1068 | \image javaiterators1.png |
1069 | |
1070 | Here's how to iterate over the elements in reverse order: |
1071 | |
1072 | \snippet code/doc_src_qiterator.cpp 30 |
1073 | |
1074 | If you want to find all occurrences of a particular value, use |
1075 | findNext() or findPrevious() in a loop. For example: |
1076 | |
1077 | \snippet code/doc_src_qiterator.cpp 31 |
1078 | |
1079 | Multiple iterators can be used on the same hash. If the hash is |
1080 | modified while a QHashIterator is active, the QHashIterator will |
1081 | continue iterating over the original hash, ignoring the modified |
1082 | copy. |
1083 | |
1084 | \sa QMutableHashIterator, QHash::const_iterator |
1085 | */ |
1086 | |
1087 | /*! |
1088 | \class QMutableMapIterator |
1089 | \inmodule QtCore |
1090 | |
1091 | \brief The QMutableMapIterator class provides a Java-style non-const iterator for QMap and QMultiMap. |
1092 | |
1093 | QMap has both \l{Java-style iterators} and \l{STL-style |
1094 | iterators}. The Java-style iterators are more high-level and |
1095 | easier to use than the STL-style iterators; on the other hand, |
1096 | they are slightly less efficient. |
1097 | |
1098 | QMutableMapIterator\<Key, T\> allows you to iterate over a QMap |
1099 | (or a QMultiMap) and modify the map. If you don't want to modify |
1100 | the map (or have a const QMap), use the slightly faster |
1101 | QMapIterator instead. |
1102 | |
1103 | The QMutableMapIterator constructor takes a QMap as argument. |
1104 | After construction, the iterator is located at the very beginning |
1105 | of the map (before the first item). Here's how to iterate over |
1106 | all the elements sequentially: |
1107 | |
1108 | \snippet code/doc_src_qiterator.cpp 32 |
1109 | |
1110 | The next() function returns the next item in the map and |
1111 | advances the iterator. The key() and value() functions return the |
1112 | key and value of the last item that was jumped over. |
1113 | |
1114 | Unlike STL-style iterators, Java-style iterators point \e between |
1115 | items rather than directly \e at items. The first call to next() |
1116 | advances the iterator to the position between the first and |
1117 | second item, and returns the first item; the second call to |
1118 | next() advances the iterator to the position between the second |
1119 | and third item; and so on. |
1120 | |
1121 | \image javaiterators1.png |
1122 | |
1123 | Here's how to iterate over the elements in reverse order: |
1124 | |
1125 | \snippet code/doc_src_qiterator.cpp 33 |
1126 | |
1127 | If you want to find all occurrences of a particular value, use |
1128 | findNext() or findPrevious() in a loop. For example: |
1129 | |
1130 | \snippet code/doc_src_qiterator.cpp 34 |
1131 | |
1132 | If you want to remove items as you iterate over the map, use |
1133 | remove(). If you want to modify the value of an item, use |
1134 | setValue(). |
1135 | |
1136 | Example: |
1137 | |
1138 | \snippet code/doc_src_qiterator.cpp 35 |
1139 | |
1140 | The example removes all (key, value) pairs where the key and the |
1141 | value are the same. |
1142 | |
1143 | Only one mutable iterator can be active on a given map at any |
1144 | time. Furthermore, no changes should be done directly to the map |
1145 | while the iterator is active (as opposed to through the |
1146 | iterator), since this could invalidate the iterator and lead to |
1147 | undefined behavior. |
1148 | |
1149 | \sa QMapIterator, QMap::iterator |
1150 | */ |
1151 | |
1152 | /*! |
1153 | \class QMutableHashIterator |
1154 | \inmodule QtCore |
1155 | |
1156 | \brief The QMutableHashIterator class provides a Java-style non-const iterator for QHash and QMultiHash. |
1157 | |
1158 | QHash has both \l{Java-style iterators} and \l{STL-style |
1159 | iterators}. The Java-style iterators are more high-level and |
1160 | easier to use than the STL-style iterators; on the other hand, |
1161 | they are slightly less efficient. |
1162 | |
1163 | QMutableHashIterator\<Key, T\> allows you to iterate over a QHash |
1164 | (or a QMultiHash) and modify the hash. If you don't want to modify |
1165 | the hash (or have a const QHash), use the slightly faster |
1166 | QHashIterator instead. |
1167 | |
1168 | The QMutableHashIterator constructor takes a QHash as argument. |
1169 | After construction, the iterator is located at the very beginning |
1170 | of the hash (before the first item). Here's how to iterate over |
1171 | all the elements sequentially: |
1172 | |
1173 | \snippet code/doc_src_qiterator.cpp 36 |
1174 | |
1175 | The next() function returns the next item in the hash and |
1176 | advances the iterator. The key() and value() functions return the |
1177 | key and value of the last item that was jumped over. |
1178 | |
1179 | Unlike STL-style iterators, Java-style iterators point \e between |
1180 | items rather than directly \e at items. The first call to next() |
1181 | advances the iterator to the position between the first and |
1182 | second item, and returns the first item; the second call to |
1183 | next() advances the iterator to the position between the second |
1184 | and third item; and so on. |
1185 | |
1186 | \image javaiterators1.png |
1187 | |
1188 | Here's how to iterate over the elements in reverse order: |
1189 | |
1190 | \snippet code/doc_src_qiterator.cpp 37 |
1191 | |
1192 | If you want to find all occurrences of a particular value, use |
1193 | findNext() or findPrevious() in a loop. For example: |
1194 | |
1195 | \snippet code/doc_src_qiterator.cpp 38 |
1196 | |
1197 | If you want to remove items as you iterate over the hash, use |
1198 | remove(). If you want to modify the value of an item, use |
1199 | setValue(). |
1200 | |
1201 | Example: |
1202 | |
1203 | \snippet code/doc_src_qiterator.cpp 39 |
1204 | |
1205 | The example removes all (key, value) pairs where the key and the |
1206 | value are the same. |
1207 | |
1208 | Only one mutable iterator can be active on a given hash at any |
1209 | time. Furthermore, no changes should be done directly to the hash |
1210 | while the iterator is active (as opposed to through the |
1211 | iterator), since this could invalidate the iterator and lead to |
1212 | undefined behavior. |
1213 | |
1214 | \sa QHashIterator, QHash::iterator |
1215 | */ |
1216 | |
1217 | /*! \fn template <class Key, class T> QMapIterator<Key, T>::QMapIterator(const QMap<Key, T> &map) |
1218 | \fn template <class Key, class T> QMutableMapIterator<Key, T>::QMutableMapIterator(QMap<Key, T> &map) |
1219 | |
1220 | Constructs an iterator for traversing \a map. The iterator is set |
1221 | to be at the front of the map (before the first item). |
1222 | |
1223 | \sa operator=() |
1224 | */ |
1225 | |
1226 | /*! \fn template <class Key, class T> QHashIterator<Key, T>::QHashIterator(const QHash<Key, T> &hash) |
1227 | \fn template <class Key, class T> QMutableHashIterator<Key, T>::QMutableHashIterator(QHash<Key, T> &hash) |
1228 | |
1229 | Constructs an iterator for traversing \a hash. The iterator is |
1230 | set to be at the front of the hash (before the first item). |
1231 | |
1232 | \sa operator=() |
1233 | */ |
1234 | |
1235 | /*! \fn template <class Key, class T> QMapIterator &QMapIterator<Key, T>::operator=(const QMap<Key, T> &map) |
1236 | \fn template <class Key, class T> QMutableMapIterator &QMutableMapIterator<Key, T>::operator=(QMap<Key, T> &map) |
1237 | |
1238 | Makes the iterator operate on \a map. The iterator is set to be |
1239 | at the front of the map (before the first item). |
1240 | |
1241 | \sa toFront(), toBack() |
1242 | */ |
1243 | |
1244 | /*! \fn template <class Key, class T> QHashIterator &QHashIterator<Key, T>::operator=(const QHash<Key, T> &hash) |
1245 | \fn template <class Key, class T> QMutableHashIterator &QMutableHashIterator<Key, T>::operator=(QHash<Key, T> &hash) |
1246 | |
1247 | Makes the iterator operate on \a hash. The iterator is set to be |
1248 | at the front of the hash (before the first item). |
1249 | |
1250 | \sa toFront(), toBack() |
1251 | */ |
1252 | |
1253 | /*! \fn template <class Key, class T> void QMapIterator<Key, T>::toFront() |
1254 | \fn template <class Key, class T> void QHashIterator<Key, T>::toFront() |
1255 | \fn template <class Key, class T> void QMutableMapIterator<Key, T>::toFront() |
1256 | \fn template <class Key, class T> void QMutableHashIterator<Key, T>::toFront() |
1257 | |
1258 | Moves the iterator to the front of the container (before the |
1259 | first item). |
1260 | |
1261 | \sa toBack(), next() |
1262 | */ |
1263 | |
1264 | /*! \fn template <class Key, class T> void QMapIterator<Key, T>::toBack() |
1265 | \fn template <class Key, class T> void QHashIterator<Key, T>::toBack() |
1266 | \fn template <class Key, class T> void QMutableMapIterator<Key, T>::toBack() |
1267 | \fn template <class Key, class T> void QMutableHashIterator<Key, T>::toBack() |
1268 | |
1269 | Moves the iterator to the back of the container (after the last |
1270 | item). |
1271 | |
1272 | \sa toFront(), previous() |
1273 | */ |
1274 | |
1275 | /*! \fn template <class Key, class T> bool QMapIterator<Key, T>::hasNext() const |
1276 | \fn template <class Key, class T> bool QHashIterator<Key, T>::hasNext() const |
1277 | \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::hasNext() const |
1278 | \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::hasNext() const |
1279 | |
1280 | Returns \c true if there is at least one item ahead of the iterator, |
1281 | i.e. the iterator is \e not at the back of the container; |
1282 | otherwise returns \c false. |
1283 | |
1284 | \sa hasPrevious(), next() |
1285 | */ |
1286 | |
1287 | /*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::next() |
1288 | \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::next() |
1289 | |
1290 | Returns the next item and advances the iterator by one position. |
1291 | |
1292 | Call key() on the return value to obtain the item's key, and |
1293 | value() to obtain the value. |
1294 | |
1295 | Calling this function on an iterator located at the back of the |
1296 | container leads to undefined results. |
1297 | |
1298 | \sa hasNext(), peekNext(), previous() |
1299 | */ |
1300 | |
1301 | /*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::next() |
1302 | \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::next() |
1303 | |
1304 | Returns the next item and advances the iterator by one position. |
1305 | |
1306 | Call key() on the return value to obtain the item's key, and |
1307 | value() to obtain the value. |
1308 | |
1309 | Calling this function on an iterator located at the back of the |
1310 | container leads to undefined results. |
1311 | |
1312 | \sa hasNext(), peekNext(), previous() |
1313 | */ |
1314 | |
1315 | /*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::peekNext() const |
1316 | \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::peekNext() const |
1317 | |
1318 | Returns the next item without moving the iterator. |
1319 | |
1320 | Call key() on the return value to obtain the item's key, and |
1321 | value() to obtain the value. |
1322 | |
1323 | Calling this function on an iterator located at the back of the |
1324 | container leads to undefined results. |
1325 | |
1326 | \sa hasNext(), next(), peekPrevious() |
1327 | */ |
1328 | |
1329 | /*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::peekNext() const |
1330 | \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::peekNext() const |
1331 | |
1332 | Returns a reference to the next item without moving the iterator. |
1333 | |
1334 | Call key() on the return value to obtain the item's key, and |
1335 | value() to obtain the value. |
1336 | |
1337 | Calling this function on an iterator located at the back of the |
1338 | container leads to undefined results. |
1339 | |
1340 | \sa hasNext(), next(), peekPrevious() |
1341 | */ |
1342 | |
1343 | /*! \fn template <class Key, class T> bool QMapIterator<Key, T>::hasPrevious() const |
1344 | \fn template <class Key, class T> bool QHashIterator<Key, T>::hasPrevious() const |
1345 | \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::hasPrevious() const |
1346 | \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::hasPrevious() const |
1347 | |
1348 | Returns \c true if there is at least one item behind the iterator, |
1349 | i.e. the iterator is \e not at the front of the container; |
1350 | otherwise returns \c false. |
1351 | |
1352 | \sa hasNext(), previous() |
1353 | */ |
1354 | |
1355 | /*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::previous() |
1356 | \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::previous() |
1357 | |
1358 | Returns the previous item and moves the iterator back by one |
1359 | position. |
1360 | |
1361 | Call key() on the return value to obtain the item's key, and |
1362 | value() to obtain the value. |
1363 | |
1364 | Calling this function on an iterator located at the front of the |
1365 | container leads to undefined results. |
1366 | |
1367 | \sa hasPrevious(), peekPrevious(), next() |
1368 | */ |
1369 | |
1370 | /*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::previous() |
1371 | \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::previous() |
1372 | |
1373 | Returns the previous item and moves the iterator back by one |
1374 | position. |
1375 | |
1376 | Call key() on the return value to obtain the item's key, and |
1377 | value() to obtain the value. |
1378 | |
1379 | Calling this function on an iterator located at the front of the |
1380 | container leads to undefined results. |
1381 | |
1382 | \sa hasPrevious(), peekPrevious(), next() |
1383 | */ |
1384 | |
1385 | /*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::peekPrevious() const |
1386 | \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::peekPrevious() const |
1387 | |
1388 | Returns the previous item without moving the iterator. |
1389 | |
1390 | Call key() on the return value to obtain the item's key, and |
1391 | value() to obtain the value. |
1392 | |
1393 | Calling this function on an iterator located at the front of the |
1394 | container leads to undefined results. |
1395 | |
1396 | \sa hasPrevious(), previous(), peekNext() |
1397 | */ |
1398 | |
1399 | /*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::peekPrevious() const |
1400 | \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::peekPrevious() const |
1401 | |
1402 | Returns the previous item without moving the iterator. |
1403 | |
1404 | Call key() on the return value to obtain the item's key, and |
1405 | value() to obtain the value. |
1406 | |
1407 | Calling this function on an iterator located at the front of the |
1408 | container leads to undefined results. |
1409 | |
1410 | \sa hasPrevious(), previous(), peekNext() |
1411 | */ |
1412 | |
1413 | /*! \fn template <class Key, class T> const T &QMapIterator<Key, T>::value() const |
1414 | \fn template <class Key, class T> const T &QHashIterator<Key, T>::value() const |
1415 | |
1416 | Returns the value of the last item that was jumped over using one |
1417 | of the traversal functions (next(), previous(), findNext(), |
1418 | findPrevious()). |
1419 | |
1420 | After a call to next() or findNext(), value() is |
1421 | equivalent to peekPrevious().value(). After a call to previous() |
1422 | or findPrevious(), value() is equivalent to peekNext().value(). |
1423 | |
1424 | \sa key() |
1425 | */ |
1426 | |
1427 | /*! |
1428 | \fn template <class Key, class T> const T &QMutableMapIterator<Key, T>::value() const |
1429 | \fn template <class Key, class T> const T &QMutableHashIterator<Key, T>::value() const |
1430 | |
1431 | Returns the value of the last item that was jumped over using one |
1432 | of the traversal functions (next(), previous(), findNext(), |
1433 | findPrevious()). |
1434 | |
1435 | After a call to next() or findNext(), value() is |
1436 | equivalent to peekPrevious().value(). After a call to previous() |
1437 | or findPrevious(), value() is equivalent to peekNext().value(). |
1438 | |
1439 | \sa key(), setValue() |
1440 | */ |
1441 | |
1442 | /*! |
1443 | \fn template <class Key, class T> T &QMutableMapIterator<Key, T>::value() |
1444 | \fn template <class Key, class T> T &QMutableHashIterator<Key, T>::value() |
1445 | \overload |
1446 | |
1447 | Returns a non-const reference to the value of |
1448 | the last item that was jumped over using one |
1449 | of the traversal functions. |
1450 | */ |
1451 | |
1452 | /*! \fn template <class Key, class T> const Key &QMapIterator<Key, T>::key() const |
1453 | \fn template <class Key, class T> const Key &QHashIterator<Key, T>::key() const |
1454 | \fn template <class Key, class T> const Key &QMutableMapIterator<Key, T>::key() const |
1455 | \fn template <class Key, class T> const Key &QMutableHashIterator<Key, T>::key() const |
1456 | |
1457 | Returns the key of the last item that was jumped over using one |
1458 | of the traversal functions (next(), previous(), findNext(), |
1459 | findPrevious()). |
1460 | |
1461 | After a call to next() or findNext(), key() is |
1462 | equivalent to peekPrevious().key(). After a call to previous() or |
1463 | findPrevious(), key() is equivalent to peekNext().key(). |
1464 | |
1465 | \sa value() |
1466 | */ |
1467 | |
1468 | /*! \fn template <class Key, class T> bool QMapIterator<Key, T>::findNext(const T &value) |
1469 | \fn template <class Key, class T> bool QHashIterator<Key, T>::findNext(const T &value) |
1470 | \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::findNext(const T &value) |
1471 | \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::findNext(const T &value) |
1472 | |
1473 | Searches for \a value starting from the current iterator position |
1474 | forward. Returns \c true if a (key, value) pair with value \a value |
1475 | is found; otherwise returns \c false. |
1476 | |
1477 | After the call, if \a value was found, the iterator is positioned |
1478 | just after the matching item; otherwise, the iterator is |
1479 | positioned at the back of the container. |
1480 | |
1481 | \sa findPrevious() |
1482 | */ |
1483 | |
1484 | /*! \fn template <class Key, class T> bool QMapIterator<Key, T>::findPrevious(const T &value) |
1485 | \fn template <class Key, class T> bool QHashIterator<Key, T>::findPrevious(const T &value) |
1486 | \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::findPrevious(const T &value) |
1487 | \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::findPrevious(const T &value) |
1488 | |
1489 | Searches for \a value starting from the current iterator position |
1490 | backward. Returns \c true if a (key, value) pair with value \a value |
1491 | is found; otherwise returns \c false. |
1492 | |
1493 | After the call, if \a value was found, the iterator is positioned |
1494 | just before the matching item; otherwise, the iterator is |
1495 | positioned at the front of the container. |
1496 | |
1497 | \sa findNext() |
1498 | */ |
1499 | |
1500 | /*! \fn template <class Key, class T> void QMutableMapIterator<Key, T>::remove() |
1501 | \fn template <class Key, class T> void QMutableHashIterator<Key, T>::remove() |
1502 | |
1503 | Removes the last item that was jumped over using one of the |
1504 | traversal functions (next(), previous(), findNext(), findPrevious()). |
1505 | |
1506 | \sa setValue() |
1507 | */ |
1508 | |
1509 | /*! \fn template <class Key, class T> void QMutableMapIterator<Key, T>::setValue(const T &value) |
1510 | \fn template <class Key, class T> void QMutableHashIterator<Key, T>::setValue(const T &value) |
1511 | |
1512 | Replaces the value of the last item that was jumped over using |
1513 | one of the traversal functions with \a value. |
1514 | |
1515 | The traversal functions are next(), previous(), findNext(), and |
1516 | findPrevious(). |
1517 | |
1518 | \sa key(), value(), remove() |
1519 | */ |
1520 |
Warning: That file was not part of the compilation database. It may have many parsing errors.