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