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