Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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, QtPrivate::IfIsInputIterator<InputIterator> = true> 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 &lhs, const QSet &rhs)
571 \fn template <class T> QSet<T> QSet<T>::operator|(QSet &&lhs, const QSet &rhs)
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+(QSet &&lhs, const QSet &rhs)
574
575 Returns a new QSet that is the union of sets \a lhs and \a rhs.
576
577 \sa unite(), operator|=(), operator&(), operator-()
578*/
579
580/*!
581 \fn template <class T> QSet<T> QSet<T>::operator&(const QSet &lhs, const QSet &rhs)
582 \fn template <class T> QSet<T> QSet<T>::operator&(QSet &&lhs, const QSet &rhs)
583
584 Returns a new QSet that is the intersection of sets \a lhs and \a rhs.
585
586 \sa intersect(), operator&=(), operator|(), operator-()
587*/
588
589/*!
590 \fn template <class T> QSet<T> QSet<T>::operator-(const QSet &lhs, const QSet &rhs)
591 \fn template <class T> QSet<T> QSet<T>::operator-(QSet &&lhs, const QSet &rhs)
592
593 Returns a new QSet that is the set difference of sets \a lhs and \a rhs.
594
595 \sa subtract(), operator-=(), operator|(), operator&()
596*/
597
598/*!
599 \class QSet::iterator
600 \inmodule QtCore
601 \since 4.2
602 \brief The QSet::iterator class provides an STL-style non-const iterator for QSet.
603
604 QSet features both \l{STL-style iterators} and
605 \l{Java-style iterators}. The STL-style iterators are more
606 low-level and more cumbersome to use; on the other hand, they are
607 slightly faster and, for developers who already know STL, have
608 the advantage of familiarity.
609
610 QSet<T>::iterator allows you to iterate over a QSet and to remove
611 items (using QSet::erase()) while you iterate. (QSet doesn't let
612 you \e modify a value through an iterator, because that
613 would potentially require moving the value in the internal hash
614 table used by QSet.) If you want to iterate over a const QSet,
615 you should use QSet::const_iterator. It is generally good
616 practice to use QSet::const_iterator on a non-const QSet as well,
617 unless you need to change the QSet through the iterator. Const
618 iterators are slightly faster, and can improve code readability.
619
620 The default QSet::iterator constructor creates an uninitialized
621 iterator. You must initialize it using a function like
622 QSet::begin(), QSet::end(), or QSet::insert() before you can
623 start iterating. Here's a typical loop that prints all the items
624 stored in a set:
625
626 \snippet code/doc_src_qset.cpp 8
627
628 Here's a loop that removes certain items (all those that start
629 with 'J') from a set while iterating:
630
631 \snippet code/doc_src_qset.cpp 9
632
633 STL-style iterators can be used as arguments to \l{generic
634 algorithms}. For example, here's how to find an item in the set
635 using the qFind() algorithm:
636
637 \snippet code/doc_src_qset.cpp 10
638
639 Multiple iterators can be used on the same set.
640
641 \warning Iterators on implicitly shared containers do not work
642 exactly like STL-iterators. You should avoid copying a container
643 while iterators are active on that container. For more information,
644 read \l{Implicit sharing iterator problem}.
645
646 \sa QSet::const_iterator, QMutableSetIterator
647*/
648
649/*!
650 \class QSet::const_iterator
651 \inmodule QtCore
652 \brief The QSet::const_iterator class provides an STL-style const iterator for QSet.
653 \since 4.2
654
655 QSet features both \l{STL-style iterators} and
656 \l{Java-style iterators}. The STL-style iterators are more
657 low-level and more cumbersome to use; on the other hand, they are
658 slightly faster and, for developers who already know STL, have
659 the advantage of familiarity.
660
661 QSet<Key, T>::const_iterator allows you to iterate over a QSet.
662 If you want to modify the QSet as you iterate over it, you must
663 use QSet::iterator instead. It is generally good practice to use
664 QSet::const_iterator on a non-const QSet as well, unless you need
665 to change the QSet through the iterator. Const iterators are
666 slightly faster, and can improve code readability.
667
668 The default QSet::const_iterator constructor creates an
669 uninitialized iterator. You must initialize it using a function
670 like QSet::begin(), QSet::end(), or QSet::insert() before you can
671 start iterating. Here's a typical loop that prints all the items
672 stored in a set:
673
674 \snippet code/doc_src_qset.cpp 11
675
676 STL-style iterators can be used as arguments to \l{generic
677 algorithms}. For example, here's how to find an item in the set
678 using the qFind() algorithm:
679
680 \snippet code/doc_src_qset.cpp 12
681
682 \warning Iterators on implicitly shared containers do not work
683 exactly like STL-iterators. You should avoid copying a container
684 while iterators are active on that container. For more information,
685 read \l{Implicit sharing iterator problem}.
686
687 \sa QSet::iterator, QSetIterator
688*/
689
690/*!
691 \fn template <class T> QSet<T>::iterator::iterator()
692 \fn template <class T> QSet<T>::const_iterator::const_iterator()
693
694 Constructs an uninitialized iterator.
695
696 Functions like operator*() and operator++() should not be called
697 on an uninitialized iterator. Use operator=() to assign a value
698 to it before using it.
699
700 \sa QSet::begin(), QSet::end()
701*/
702
703/*!
704 \fn template <class T> QSet<T>::iterator::iterator(typename Hash::iterator i)
705 \fn template <class T> QSet<T>::const_iterator::const_iterator(typename Hash::const_iterator i)
706
707 \internal
708*/
709
710/*!
711 \typedef QSet::iterator::iterator_category
712 \typedef QSet::const_iterator::iterator_category
713
714 Synonyms for \e {std::bidirectional_iterator_tag} indicating
715 these iterators are bidirectional iterators.
716 */
717
718/*!
719 \typedef QSet::iterator::difference_type
720 \typedef QSet::const_iterator::difference_type
721
722 \internal
723*/
724
725/*!
726 \typedef QSet::iterator::value_type
727 \typedef QSet::const_iterator::value_type
728
729 \internal
730*/
731
732/*!
733 \typedef QSet::iterator::pointer
734 \typedef QSet::const_iterator::pointer
735
736 \internal
737*/
738
739/*!
740 \typedef QSet::iterator::reference
741 \typedef QSet::const_iterator::reference
742
743 \internal
744*/
745
746/*!
747 \fn template <class T> QSet<T>::iterator::iterator(const iterator &other)
748 \fn template <class T> QSet<T>::const_iterator::const_iterator(const const_iterator &other)
749
750 Constructs a copy of \a other.
751*/
752
753/*!
754 \fn template <class T> QSet<T>::const_iterator::const_iterator(const iterator &other)
755 \since 4.2
756 \overload
757
758 Constructs a copy of \a other.
759*/
760
761/*!
762 \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator=(const iterator &other)
763 \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator=(const const_iterator &other)
764
765 Assigns \a other to this iterator.
766*/
767
768/*!
769 \fn template <class T> const T &QSet<T>::iterator::operator*() const
770 \fn template <class T> const T &QSet<T>::const_iterator::operator*() const
771
772 Returns a reference to the current item.
773
774 \sa operator->()
775*/
776
777/*!
778 \fn template <class T> const T *QSet<T>::iterator::operator->() const
779 \fn template <class T> const T *QSet<T>::const_iterator::operator->() const
780
781 Returns a pointer to the current item.
782
783 \sa operator*()
784*/
785
786/*!
787 \fn template <class T> bool QSet<T>::iterator::operator==(const iterator &other) const
788 \fn template <class T> bool QSet<T>::const_iterator::operator==(const const_iterator &other) const
789
790 Returns \c true if \a other points to the same item as this
791 iterator; otherwise returns \c false.
792
793 \sa operator!=()
794*/
795
796/*!
797 \fn template <class T> bool QSet<T>::iterator::operator==(const const_iterator &other) const
798 \fn template <class T> bool QSet<T>::iterator::operator!=(const const_iterator &other) const
799
800 \overload
801*/
802
803/*!
804 \fn template <class T> bool QSet<T>::iterator::operator!=(const iterator &other) const
805 \fn template <class T> bool QSet<T>::const_iterator::operator!=(const const_iterator &other) const
806
807 Returns \c true if \a other points to a different item than this
808 iterator; otherwise returns \c false.
809
810 \sa operator==()
811*/
812
813/*!
814 \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator++()
815 \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator++()
816
817 The prefix ++ operator (\c{++it}) advances the iterator to the
818 next item in the set and returns an iterator to the new current
819 item.
820
821 Calling this function on QSet<T>::constEnd() leads to
822 undefined results.
823*/
824
825/*!
826 \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator++(int)
827 \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator++(int)
828
829 \overload
830
831 The postfix ++ operator (\c{it++}) advances the iterator to the
832 next item in the set and returns an iterator to the previously
833 current item.
834*/
835
836/*! \fn template <class T> QList<T> QSet<T>::values() const
837
838 Returns a new QList containing the elements in the set. The
839 order of the elements in the QList is undefined.
840
841 \include containers-range-constructor.qdocinc
842
843 This function creates a new list, in \l {linear time}. The time and memory
844 use that entails can be avoided by iterating from \l constBegin() to
845 \l constEnd().
846*/
847
848
849/*!
850 \fn template <class T> QDataStream &operator<<(QDataStream &out, const QSet<T> &set)
851 \relates QSet
852
853 Writes the \a set to stream \a out.
854
855 This function requires the value type to implement \c operator<<().
856
857 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
858*/
859
860/*!
861 \fn template <class T> QDataStream &operator>>(QDataStream &in, QSet<T> &set)
862 \relates QSet
863
864 Reads a set from stream \a in into \a set.
865
866 This function requires the value type to implement \c operator>>().
867
868 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
869*/
870
871/*!
872 \fn template <class T> size_t qHash(const QSet<T> &key, size_t seed = 0)
873 \relates QHash
874 \since 5.5
875
876 Returns the hash value for the \a key, using \a seed to seed the calculation.
877
878 The hash value is independent of the order of elements in \a key, that is, sets
879 that contain the same elements hash to the same value.
880*/
881
882/*! \fn template <class T, class Predicate> qsizetype erase_if(QSet<T> &set, Predicate pred)
883 \relates QSet
884 \since 6.1
885
886 Removes all elements for which the predicate \a pred returns true
887 from the set \a set. Returns the number of elements removed, if
888 any.
889*/
890
891/*! \fn template <class T> template <class Pred> qsizetype QSet<T>::removeIf(Pred pred)
892 \since 6.1
893
894 Removes, from this set, all elements for which the predicate \a pred
895 returns \c true. Returns the number of elements removed, if any.
896*/