Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qset.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \class QSet
6 \inmodule QtCore
7 \brief The QSet class is a template class that provides a hash-table-based set.
8
9 \ingroup tools
10 \ingroup shared
11 \reentrant
12
13
14 QSet<T> is one of Qt's generic \l{container classes}. It stores
15 values in an unspecified order and provides very fast lookup of
16 the values. Internally, QSet<T> is implemented as a QHash.
17
18 Here's an example QSet with QString values:
19
20 \snippet code/doc_src_qset.cpp 0
21
22 To insert a value into the set, use insert():
23
24 \snippet code/doc_src_qset.cpp 1
25
26 Another way to insert items into the set is to use \l operator<<():
27
28 \snippet code/doc_src_qset.cpp 2
29
30 To test whether an item belongs to the set or not, use contains():
31
32 \snippet code/doc_src_qset.cpp 3
33
34 If you want to navigate through all the values stored in a QSet,
35 you can use an iterator. QSet supports both \l{Java-style
36 iterators} (QSetIterator and QMutableSetIterator) and \l{STL-style
37 iterators} (QSet::iterator and QSet::const_iterator). Here's how
38 to iterate over a QSet<QWidget *> using a Java-style iterator:
39
40 \snippet code/doc_src_qset.cpp 4
41
42 Here's the same code, but using an STL-style iterator:
43
44 \snippet code/doc_src_qset.cpp 5
45
46 QSet is unordered, so an iterator's sequence cannot be assumed to
47 be predictable. If ordering by key is required, use a QMap.
48
49 To navigate through a QSet, you can also use range-based for:
50
51 \snippet code/doc_src_qset.cpp 6
52
53 Items can be removed from the set using remove(). There is also a
54 clear() function that removes all items.
55
56 QSet's value data type must be an \l{assignable data type}. You
57 cannot, for example, store a QWidget as a value; instead, store a
58 QWidget *. In addition, the type must provide \c operator==(), and
59 there must also be a global qHash() function that returns a hash
60 value for an argument of the key's type. See the QHash
61 documentation for a list of types supported by qHash().
62
63 Internally, QSet uses a hash table to perform lookups. The hash
64 table automatically grows and shrinks to provide fast lookups
65 without wasting memory. You can still control the size of the hash
66 table by calling reserve(), if you already know approximately how
67 many elements the QSet will contain, but this isn't necessary to
68 obtain good performance. You can also call capacity() to retrieve
69 the hash table's size.
70
71 \sa QSetIterator, QMutableSetIterator, QHash, QMap
72*/
73
74/*!
75 \fn template <class T> QSet<T>::QSet()
76
77 Constructs an empty set.
78
79 \sa clear()
80*/
81
82/*! \fn template <class T> QSet<T>::QSet(std::initializer_list<T> list)
83 \since 5.1
84
85 Constructs a set with a copy of each of the elements in the
86 initializer list \a list.
87*/
88
89/*! \fn template <class T> template<typename InputIterator> QSet<T>::QSet(InputIterator first, InputIterator last)
90 \since 5.14
91
92 Constructs a set with the contents in the iterator range [\a first, \a last).
93
94 The value type of \c InputIterator must be convertible to \c T.
95
96 \note If the range [\a first, \a last) contains duplicate elements,
97 the first one is retained.
98*/
99
100/*!
101 \fn template <class T> void QSet<T>::swap(QSet<T> &other)
102
103 Swaps set \a other with this set. This operation is very fast and
104 never fails.
105*/
106
107/*!
108 \fn template <class T> bool QSet<T>::operator==(const QSet<T> &other) const
109
110 Returns \c true if the \a other set is equal to this set; otherwise
111 returns \c false.
112
113 Two sets are considered equal if they contain the same elements.
114
115 This function requires the value type to implement \c operator==().
116
117 \sa operator!=()
118*/
119
120/*!
121 \fn template <class T> bool QSet<T>::operator!=(const QSet<T> &other) const
122
123 Returns \c true if the \a other set is not equal to this set; otherwise
124 returns \c false.
125
126 Two sets are considered equal if they contain the same elements.
127
128 This function requires the value type to implement \c operator==().
129
130 \sa operator==()
131*/
132
133/*!
134 \fn template <class T> int QSet<T>::size() const
135
136 Returns the number of items in the set.
137
138 \sa isEmpty(), count()
139*/
140
141/*!
142 \fn template <class T> bool QSet<T>::isEmpty() const
143
144 Returns \c true if the set contains no elements; otherwise returns
145 false.
146
147 \sa size()
148*/
149
150/*!
151 \fn template <class T> int QSet<T>::capacity() const
152
153 Returns the number of buckets in the set's internal hash
154 table.
155
156 The sole purpose of this function is to provide a means of fine
157 tuning QSet's memory usage. In general, you will rarely ever need
158 to call this function. If you want to know how many items are in
159 the set, call size().
160
161 \sa reserve(), squeeze()
162*/
163
164/*! \fn template <class T> void QSet<T>::reserve(qsizetype size)
165
166 Ensures that the set's internal hash table consists of at
167 least \a size buckets.
168
169 This function is useful for code that needs to build a huge set
170 and wants to avoid repeated reallocation. For example:
171
172 \snippet code/doc_src_qset.cpp 7
173
174 Ideally, \a size should be slightly more than the maximum number
175 of elements expected in the set. \a size doesn't have to be prime,
176 because QSet will use a prime number internally anyway. If \a size
177 is an underestimate, the worst that will happen is that the QSet
178 will be a bit slower.
179
180 In general, you will rarely ever need to call this function.
181 QSet's internal hash table automatically shrinks or grows to
182 provide good performance without wasting too much memory.
183
184 \sa squeeze(), capacity()
185*/
186
187/*!
188 \fn template <class T> void QSet<T>::squeeze()
189
190 Reduces the size of the set's internal hash table to save
191 memory.
192
193 The sole purpose of this function is to provide a means of fine
194 tuning QSet's memory usage. In general, you will rarely ever
195 need to call this function.
196
197 \sa reserve(), capacity()
198*/
199
200/*!
201 \fn template <class T> void QSet<T>::detach()
202
203 \internal
204
205 Detaches this set from any other sets with which it may share
206 data.
207
208 \sa isDetached()
209*/
210
211/*! \fn template <class T> bool QSet<T>::isDetached() const
212
213 \internal
214
215 Returns \c true if the set's internal data isn't shared with any
216 other set object; otherwise returns \c false.
217
218 \sa detach()
219*/
220
221/*!
222 \fn template <class T> void QSet<T>::setSharable(bool sharable)
223 \internal
224*/
225
226/*!
227 \fn template <class T> void QSet<T>::clear()
228
229 Removes all elements from the set.
230
231 \sa remove()
232*/
233
234/*!
235 \fn template <class T> bool QSet<T>::remove(const T &value)
236
237 Removes any occurrence of item \a value from the set. Returns
238 true if an item was actually removed; otherwise returns \c false.
239
240 \sa contains(), insert()
241*/
242
243/*!
244 \fn template <class T> QSet<T>::iterator QSet<T>::erase(const_iterator pos)
245 \since 5.7
246
247 Removes the item at the iterator position \a pos from the set, and
248 returns an iterator positioned at the next item in the set.
249
250 Unlike remove(), this function never causes QSet to rehash its
251 internal data structure. This means that it can safely be called
252 while iterating, and won't affect the order of items in the set.
253
254 \note The iterator \a pos \e must be valid and dereferenceable. Calling this
255 method on any other iterator, including its own \l end(), results in
256 undefined behavior. In particular, even the \l begin() iterator of an empty
257 set cannot be dereferenced.
258
259 \sa remove(), find()
260*/
261
262/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::find(const T &value) const
263 \since 4.2
264
265 Returns a const iterator positioned at the item \a value in the
266 set. If the set contains no item \a value, the function returns
267 constEnd().
268
269 \sa constFind(), contains()
270*/
271
272/*! \fn template <class T> QSet<T>::iterator QSet<T>::find(const T &value)
273 \since 4.2
274 \overload
275
276 Returns a non-const iterator positioned at the item \a value in
277 the set. If the set contains no item \a value, the function
278 returns end().
279*/
280
281/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constFind(const T &value) const
282 \since 4.2
283
284 Returns a const iterator positioned at the item \a value in the
285 set. If the set contains no item \a value, the function returns
286 constEnd().
287
288 \sa find(), contains()
289*/
290
291/*!
292 \fn template <class T> bool QSet<T>::contains(const T &value) const
293
294 Returns \c true if the set contains item \a value; otherwise returns
295 false.
296
297 \sa insert(), remove(), find()
298*/
299
300/*!
301 \fn template <class T> bool QSet<T>::contains(const QSet<T> &other) const
302 \since 4.6
303
304 Returns \c true if the set contains all items from the \a other set;
305 otherwise returns \c false.
306
307 \sa insert(), remove(), find()
308*/
309
310/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::begin() const
311
312 Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
313 item in the set.
314
315 \sa constBegin(), end()
316*/
317
318/*! \fn template <class T> QSet<T>::iterator QSet<T>::begin()
319 \since 4.2
320 \overload
321
322 Returns a non-const \l{STL-style iterators}{STL-style iterator} positioned at the first
323 item in the set.
324*/
325
326/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::cbegin() const
327 \since 5.0
328
329 Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
330 item in the set.
331
332 \sa begin(), cend()
333*/
334
335/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constBegin() const
336
337 Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
338 item in the set.
339
340 \sa begin(), constEnd()
341*/
342
343/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::end() const
344
345 Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the imaginary
346 item after the last item in the set.
347
348 \sa constEnd(), begin()
349*/
350
351/*! \fn template <class T> QSet<T>::iterator QSet<T>::end()
352 \since 4.2
353 \overload
354
355 Returns a non-const \l{STL-style iterators}{STL-style iterator} pointing to the
356 imaginary item after the last item in the set.
357*/
358
359/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::cend() const
360 \since 5.0
361
362 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
363 item after the last item in the set.
364
365 \sa cbegin(), end()
366*/
367
368/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constEnd() const
369
370 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
371 item after the last item in the set.
372
373 \sa constBegin(), end()
374*/
375
376/*!
377 \typedef QSet::Iterator
378 \since 4.2
379
380 Qt-style synonym for QSet::iterator.
381*/
382
383/*!
384 \typedef QSet::ConstIterator
385
386 Qt-style synonym for QSet::const_iterator.
387*/
388
389/*!
390 \typedef QSet::const_pointer
391
392 Typedef for const T *. Provided for STL compatibility.
393*/
394
395/*!
396 \typedef QSet::const_reference
397
398 Typedef for const T &. Provided for STL compatibility.
399*/
400
401/*!
402 \typedef QSet::difference_type
403
404 Typedef for const ptrdiff_t. Provided for STL compatibility.
405*/
406
407/*!
408 \typedef QSet::key_type
409
410 Typedef for T. Provided for STL compatibility.
411*/
412
413/*!
414 \typedef QSet::pointer
415
416 Typedef for T *. Provided for STL compatibility.
417*/
418
419/*!
420 \typedef QSet::reference
421
422 Typedef for T &. Provided for STL compatibility.
423*/
424
425/*!
426 \typedef QSet::size_type
427
428 Typedef for int. Provided for STL compatibility.
429*/
430
431/*!
432 \typedef QSet::value_type
433
434 Typedef for T. Provided for STL compatibility.
435*/
436
437/*!
438 \fn template <class T> QSet<T>::iterator QSet<T>::insert(const T &value)
439
440 Inserts item \a value into the set, if \a value isn't already
441 in the set, and returns an iterator pointing at the inserted
442 item.
443
444 \sa operator<<(), remove(), contains()
445*/
446
447/*!
448 \fn template <class T> QSet<T> &QSet<T>::unite(const QSet<T> &other)
449
450 Each item in the \a other set that isn't already in this set is
451 inserted into this set. A reference to this set is returned.
452
453 \sa operator|=(), intersect(), subtract()
454*/
455
456/*!
457 \fn template <class T> QSet<T> &QSet<T>::intersect(const QSet<T> &other)
458
459 Removes all items from this set that are not contained in the
460 \a other set. A reference to this set is returned.
461
462 \sa intersects(), operator&=(), unite(), subtract()
463*/
464
465/*!
466 \fn template <class T> bool QSet<T>::intersects(const QSet<T> &other) const
467 \since 5.6
468
469 Returns \c true if this set has at least one item in common with
470 \a other.
471
472 \sa contains(), intersect()
473*/
474
475/*!
476 \fn template <class T> QSet<T> &QSet<T>::subtract(const QSet<T> &other)
477
478 Removes all items from this set that are contained in the
479 \a other set. Returns a reference to this set.
480
481 \sa operator-=(), unite(), intersect()
482*/
483
484/*!
485 \fn template <class T> bool QSet<T>::empty() const
486
487 Returns \c true if the set is empty. This function is provided
488 for STL compatibility. It is equivalent to isEmpty().
489*/
490
491/*!
492 \fn template <class T> QSet<T>::iterator QSet<T>::insert(const_iterator it, const T &value)
493 \overload
494 \since 6.1
495
496 Inserts item \a value into the set, if \a value isn't already
497 in the set, and returns an iterator pointing at the inserted
498 item.
499
500 The iterator \a it is ignored.
501
502 This function is provided for compatibility with the STL.
503
504 \sa operator<<(), remove(), contains()
505*/
506
507/*!
508 \fn template <class T> bool QSet<T>::count() const
509
510 Same as size().
511*/
512
513/*!
514 \fn template <class T> QSet<T> &QSet<T>::operator<<(const T &value)
515 \fn template <class T> QSet<T> &QSet<T>::operator+=(const T &value)
516 \fn template <class T> QSet<T> &QSet<T>::operator|=(const T &value)
517
518 Inserts a new item \a value and returns a reference to the set.
519 If \a value already exists in the set, the set is left unchanged.
520
521 \sa insert()
522*/
523
524/*!
525 \fn template <class T> QSet<T> &QSet<T>::operator-=(const T &value)
526
527 Removes the occurrence of item \a value from the set, if
528 it is found, and returns a reference to the set. If the
529 \a value is not contained the set, nothing is removed.
530
531 \sa remove()
532*/
533
534/*!
535 \fn template <class T> QSet<T> &QSet<T>::operator|=(const QSet<T> &other)
536 \fn template <class T> QSet<T> &QSet<T>::operator+=(const QSet<T> &other)
537
538 Same as \l {unite()} {unite(\a other)}.
539
540 \sa operator|(), operator&=(), operator-=()
541*/
542
543/*!
544 \fn template <class T> QSet<T> &QSet<T>::operator&=(const QSet<T> &other)
545
546 Same as \l {intersect()} {intersect(\a other)}.
547
548 \sa operator&(), operator|=(), operator-=()
549*/
550
551/*!
552 \fn template <class T> QSet<T> &QSet<T>::operator&=(const T &value)
553
554 \overload
555
556 Same as \l {intersect()} {intersect(\e{other})}, if we consider \e other to be a set
557 that contains the singleton \a value.
558*/
559
560
561/*!
562 \fn template <class T> QSet<T> &QSet<T>::operator-=(const QSet<T> &other)
563
564 Same as \l {subtract()} {subtract(\a{other})}.
565
566 \sa operator-(), operator|=(), operator&=()
567*/
568
569/*!
570 \fn template <class T> QSet<T> QSet<T>::operator|(const QSet<T> &other) const
571 \fn template <class T> QSet<T> QSet<T>::operator+(const QSet<T> &other) const
572
573 Returns a new QSet that is the union of this set and the
574 \a other set.
575
576 \sa unite(), operator|=(), operator&(), operator-()
577*/
578
579/*!
580 \fn template <class T> QSet<T> QSet<T>::operator&(const QSet<T> &other) const
581
582 Returns a new QSet that is the intersection of this set and the
583 \a other set.
584
585 \sa intersect(), operator&=(), operator|(), operator-()
586*/
587
588/*!
589 \fn template <class T> QSet<T> QSet<T>::operator-(const QSet<T> &other) const
590
591 Returns a new QSet that is the set difference of this set and
592 the \a other set, i.e., this set - \a other set.
593
594 \sa subtract(), operator-=(), operator|(), operator&()
595*/
596
597/*!
598 \class QSet::iterator
599 \inmodule QtCore
600 \since 4.2
601 \brief The QSet::iterator class provides an STL-style non-const iterator for QSet.
602
603 QSet features both \l{STL-style iterators} and
604 \l{Java-style iterators}. The STL-style iterators are more
605 low-level and more cumbersome to use; on the other hand, they are
606 slightly faster and, for developers who already know STL, have
607 the advantage of familiarity.
608
609 QSet<T>::iterator allows you to iterate over a QSet and to remove
610 items (using QSet::erase()) while you iterate. (QSet doesn't let
611 you \e modify a value through an iterator, because that
612 would potentially require moving the value in the internal hash
613 table used by QSet.) If you want to iterate over a const QSet,
614 you should use QSet::const_iterator. It is generally good
615 practice to use QSet::const_iterator on a non-const QSet as well,
616 unless you need to change the QSet through the iterator. Const
617 iterators are slightly faster, and can improve code readability.
618
619 The default QSet::iterator constructor creates an uninitialized
620 iterator. You must initialize it using a function like
621 QSet::begin(), QSet::end(), or QSet::insert() before you can
622 start iterating. Here's a typical loop that prints all the items
623 stored in a set:
624
625 \snippet code/doc_src_qset.cpp 8
626
627 Here's a loop that removes certain items (all those that start
628 with 'J') from a set while iterating:
629
630 \snippet code/doc_src_qset.cpp 9
631
632 STL-style iterators can be used as arguments to \l{generic
633 algorithms}. For example, here's how to find an item in the set
634 using the qFind() algorithm:
635
636 \snippet code/doc_src_qset.cpp 10
637
638 Multiple iterators can be used on the same set.
639
640 \warning Iterators on implicitly shared containers do not work
641 exactly like STL-iterators. You should avoid copying a container
642 while iterators are active on that container. For more information,
643 read \l{Implicit sharing iterator problem}.
644
645 \sa QSet::const_iterator, QMutableSetIterator
646*/
647
648/*!
649 \class QSet::const_iterator
650 \inmodule QtCore
651 \brief The QSet::const_iterator class provides an STL-style const iterator for QSet.
652 \since 4.2
653
654 QSet features both \l{STL-style iterators} and
655 \l{Java-style iterators}. The STL-style iterators are more
656 low-level and more cumbersome to use; on the other hand, they are
657 slightly faster and, for developers who already know STL, have
658 the advantage of familiarity.
659
660 QSet<Key, T>::const_iterator allows you to iterate over a QSet.
661 If you want to modify the QSet as you iterate over it, you must
662 use QSet::iterator instead. It is generally good practice to use
663 QSet::const_iterator on a non-const QSet as well, unless you need
664 to change the QSet through the iterator. Const iterators are
665 slightly faster, and can improve code readability.
666
667 The default QSet::const_iterator constructor creates an
668 uninitialized iterator. You must initialize it using a function
669 like QSet::begin(), QSet::end(), or QSet::insert() before you can
670 start iterating. Here's a typical loop that prints all the items
671 stored in a set:
672
673 \snippet code/doc_src_qset.cpp 11
674
675 STL-style iterators can be used as arguments to \l{generic
676 algorithms}. For example, here's how to find an item in the set
677 using the qFind() algorithm:
678
679 \snippet code/doc_src_qset.cpp 12
680
681 \warning Iterators on implicitly shared containers do not work
682 exactly like STL-iterators. You should avoid copying a container
683 while iterators are active on that container. For more information,
684 read \l{Implicit sharing iterator problem}.
685
686 \sa QSet::iterator, QSetIterator
687*/
688
689/*!
690 \fn template <class T> QSet<T>::iterator::iterator()
691 \fn template <class T> QSet<T>::const_iterator::const_iterator()
692
693 Constructs an uninitialized iterator.
694
695 Functions like operator*() and operator++() should not be called
696 on an uninitialized iterator. Use operator=() to assign a value
697 to it before using it.
698
699 \sa QSet::begin(), QSet::end()
700*/
701
702/*!
703 \fn template <class T> QSet<T>::iterator::iterator(typename Hash::iterator i)
704 \fn template <class T> QSet<T>::const_iterator::const_iterator(typename Hash::const_iterator i)
705
706 \internal
707*/
708
709/*!
710 \typedef QSet::iterator::iterator_category
711 \typedef QSet::const_iterator::iterator_category
712
713 Synonyms for \e {std::bidirectional_iterator_tag} indicating
714 these iterators are bidirectional iterators.
715 */
716
717/*!
718 \typedef QSet::iterator::difference_type
719 \typedef QSet::const_iterator::difference_type
720
721 \internal
722*/
723
724/*!
725 \typedef QSet::iterator::value_type
726 \typedef QSet::const_iterator::value_type
727
728 \internal
729*/
730
731/*!
732 \typedef QSet::iterator::pointer
733 \typedef QSet::const_iterator::pointer
734
735 \internal
736*/
737
738/*!
739 \typedef QSet::iterator::reference
740 \typedef QSet::const_iterator::reference
741
742 \internal
743*/
744
745/*!
746 \fn template <class T> QSet<T>::iterator::iterator(const iterator &other)
747 \fn template <class T> QSet<T>::const_iterator::const_iterator(const const_iterator &other)
748
749 Constructs a copy of \a other.
750*/
751
752/*!
753 \fn template <class T> QSet<T>::const_iterator::const_iterator(const iterator &other)
754 \since 4.2
755 \overload
756
757 Constructs a copy of \a other.
758*/
759
760/*!
761 \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator=(const iterator &other)
762 \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator=(const const_iterator &other)
763
764 Assigns \a other to this iterator.
765*/
766
767/*!
768 \fn template <class T> const T &QSet<T>::iterator::operator*() const
769 \fn template <class T> const T &QSet<T>::const_iterator::operator*() const
770
771 Returns a reference to the current item.
772
773 \sa operator->()
774*/
775
776/*!
777 \fn template <class T> const T *QSet<T>::iterator::operator->() const
778 \fn template <class T> const T *QSet<T>::const_iterator::operator->() const
779
780 Returns a pointer to the current item.
781
782 \sa operator*()
783*/
784
785/*!
786 \fn template <class T> bool QSet<T>::iterator::operator==(const iterator &other) const
787 \fn template <class T> bool QSet<T>::const_iterator::operator==(const const_iterator &other) const
788
789 Returns \c true if \a other points to the same item as this
790 iterator; otherwise returns \c false.
791
792 \sa operator!=()
793*/
794
795/*!
796 \fn template <class T> bool QSet<T>::iterator::operator==(const const_iterator &other) const
797 \fn template <class T> bool QSet<T>::iterator::operator!=(const const_iterator &other) const
798
799 \overload
800*/
801
802/*!
803 \fn template <class T> bool QSet<T>::iterator::operator!=(const iterator &other) const
804 \fn template <class T> bool QSet<T>::const_iterator::operator!=(const const_iterator &other) const
805
806 Returns \c true if \a other points to a different item than this
807 iterator; otherwise returns \c false.
808
809 \sa operator==()
810*/
811
812/*!
813 \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator++()
814 \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator++()
815
816 The prefix ++ operator (\c{++it}) advances the iterator to the
817 next item in the set and returns an iterator to the new current
818 item.
819
820 Calling this function on QSet<T>::constEnd() leads to
821 undefined results.
822*/
823
824/*!
825 \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator++(int)
826 \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator++(int)
827
828 \overload
829
830 The postfix ++ operator (\c{it++}) advances the iterator to the
831 next item in the set and returns an iterator to the previously
832 current item.
833*/
834
835/*! \fn template <class T> QList<T> QSet<T>::values() const
836
837 Returns a new QList containing the elements in the set. The
838 order of the elements in the QList is undefined.
839
840 \include containers-range-constructor.qdocinc
841
842 This function creates a new list, in \l {linear time}. The time and memory
843 use that entails can be avoided by iterating from \l constBegin() to
844 \l constEnd().
845*/
846
847
848/*!
849 \fn template <class T> QDataStream &operator<<(QDataStream &out, const QSet<T> &set)
850 \relates QSet
851
852 Writes the \a set to stream \a out.
853
854 This function requires the value type to implement \c operator<<().
855
856 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
857*/
858
859/*!
860 \fn template <class T> QDataStream &operator>>(QDataStream &in, QSet<T> &set)
861 \relates QSet
862
863 Reads a set from stream \a in into \a set.
864
865 This function requires the value type to implement \c operator>>().
866
867 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
868*/
869
870/*!
871 \fn template <class T> size_t qHash(const QSet<T> &key, size_t seed = 0)
872 \relates QHash
873 \since 5.5
874
875 Returns the hash value for the \a key, using \a seed to seed the calculation.
876
877 The hash value is independent of the order of elements in \a key, that is, sets
878 that contain the same elements hash to the same value.
879*/
880
881/*! \fn template <class T, class Predicate> qsizetype erase_if(QSet<T> &set, Predicate pred)
882 \relates QSet
883 \since 6.1
884
885 Removes all elements for which the predicate \a pred returns true
886 from the set \a set. Returns the number of elements removed, if
887 any.
888*/