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
doc_src_qset.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [0]
6//! [0]
7
8
9//! [1]
10set.insert("one");
11set.insert("three");
12set.insert("seven");
13//! [1]
14
15
16//! [2]
17set << "twelve" << "fifteen" << "nineteen";
18//! [2]
19
20
21//! [3]
22if (!set.contains("ninety-nine"))
23 ...
24//! [3]
25
26
27//! [4]
28QSetIterator<QWidget *> i(set);
29while (i.hasNext()) {
30 QWidget *w = i.next();
31 qDebug() << w;
32}
33//! [4]
34
35
36//! [5]
37for (auto i = set.cbegin(), end = set.cend(); i != end; ++i)
38 qDebug() << *i;
39//! [5]
40
41
42//! [6]
44...
45for (const auto &value : set)
46 qDebug() << value;
47//! [6]
48
49
50//! [7]
52set.reserve(20000);
53for (int i = 0; i < 20000; ++i)
54 set.insert(values[i]);
55//! [7]
56
57
58//! [8]
59QSet<QString> set = {"January", "February", ... "December"}
60
61// i is a QSet<QString>::iterator
62for (auto i = set.begin(), end = set.end(); i != end; ++i)
63 qDebug() << *i;
64//! [8]
65
66
67//! [9]
68QSet<QString> set = {"January", "February", ... "December"};
69
70auto i = set.begin();
71while (i != set.end()) {
72 if ((*i).startsWith('J')) {
73 i = set.erase(i);
74 } else {
75 ++i;
76 }
77}
78//! [9]
79
80
81//! [10]
83...
84const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; };
85QSet<QString>::iterator it = std::find_if(set.begin(), set.end(), predicate);
86if (it != set.end())
87 cout << "Found Jeanette" << endl;
88//! [10]
89
90
91//! [11]
92QSet<QString> set = {"January", "February", ... "December"};
93
94// i is QSet<QString>::const_iterator
95for (auto i = set.cbegin(), end = set.cend(); i != end; ++i)
96 qDebug() << *i;
97//! [11]
98
99
100//! [12]
102...
103const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; };
104QSet<QString>::const_iterator it = std::find_if(set.cbegin(), set.cend(), predicate);
105if (it != set.constEnd())
106 cout << "Found Jeanette" << endl;
107//! [12]
QSet< QString >::iterator it
[0]
auto i
QFuture< QSet< QChar > > set
[10]