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