blob: 7469d2ac5f601b363268f5f6eba0abc26be9586d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
//! [0]
QSet<QString> set;
//! [0]
//! [1]
set.insert("one");
set.insert("three");
set.insert("seven");
//! [1]
//! [2]
set << "twelve" << "fifteen" << "nineteen";
//! [2]
//! [3]
if (!set.contains("ninety-nine"))
...
//! [3]
//! [4]
QSetIterator<QWidget *> i(set);
while (i.hasNext())
qDebug() << i.next();
//! [4]
//! [5]
QSet<QWidget *>::const_iterator i = set.constBegin();
while (i != set.constEnd()) {
qDebug() << *i;
++i;
}
//! [5]
//! [6]
QSet<QString> set;
...
foreach (QString value, set)
qDebug() << value;
//! [6]
//! [7]
QSet<QString> set;
set.reserve(20000);
for (int i = 0; i < 20000; ++i)
set.insert(values[i]);
//! [7]
//! [8]
QSet<QString> set;
set << "January" << "February" << ... << "December";
QSet<QString>::iterator i;
for (i = set.begin(); i != set.end(); ++i)
qDebug() << *i;
//! [8]
//! [9]
QSet<QString> set;
set << "January" << "February" << ... << "December";
QSet<QString>::iterator i = set.begin();
while (i != set.end()) {
if ((*i).startsWith('J')) {
i = set.erase(i);
} else {
++i;
}
}
//! [9]
//! [10]
QSet<QString> set;
...
QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
if (it != set.end())
cout << "Found Jeanette" << endl;
//! [10]
//! [11]
QSet<QString> set;
set << "January" << "February" << ... << "December";
QSet<QString>::const_iterator i;
for (i = set.begin(); i != set.end(); ++i)
qDebug() << *i;
//! [11]
//! [12]
QSet<QString> set;
...
QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
if (it != set.constEnd())
cout << "Found Jeanette" << endl;
//! [12]
//! [13]
QSet<QString> set;
set << "red" << "green" << "blue" << ... << "black";
QList<QString> list = set.toList();
qSort(list);
//! [13]
//! [14]
QStringList list;
list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia";
QSet<QString> set = QSet<QString>::fromList(list);
set.contains("Julia"); // returns true
set.contains("Mike"); // returns true
set.size(); // returns 2
//! [14]
|