~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qset.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/qset.qdoc -->
 
6
<head>
 
7
    <title>Qt 4.0: QSet Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QSet Class Reference</h1>
 
21
<p>The QSet class is a template class that provides a hash-table-based set. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QSet&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
24
<ul>
 
25
<li><a href="qset-members.html">List of all members, including inherited members</a></li>
 
26
</ul>
 
27
<a name="public-types"></a>
 
28
<h3>Public Types</h3>
 
29
<ul>
 
30
<li><div class="fn"/>class <b><a href="qset-const-iterator.html">const_iterator</a></b></li>
 
31
<li><div class="fn"/>typedef <b><a href="qset.html#ConstIterator-typedef">ConstIterator</a></b></li>
 
32
</ul>
 
33
<a name="public-functions"></a>
 
34
<h3>Public Functions</h3>
 
35
<ul>
 
36
<li><div class="fn"/><b><a href="qset.html#QSet">QSet</a></b> ()</li>
 
37
<li><div class="fn"/><b><a href="qset.html#QSet-2">QSet</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
38
<li><div class="fn"/>const_iterator <b><a href="qset.html#begin">begin</a></b> () const</li>
 
39
<li><div class="fn"/>int <b><a href="qset.html#capacity">capacity</a></b> () const</li>
 
40
<li><div class="fn"/>void <b><a href="qset.html#clear">clear</a></b> ()</li>
 
41
<li><div class="fn"/>const_iterator <b><a href="qset.html#constBegin">constBegin</a></b> () const</li>
 
42
<li><div class="fn"/>const_iterator <b><a href="qset.html#constEnd">constEnd</a></b> () const</li>
 
43
<li><div class="fn"/>bool <b><a href="qset.html#contains">contains</a></b> ( const T &amp; <i>value</i> ) const</li>
 
44
<li><div class="fn"/>int <b><a href="qset.html#count">count</a></b> () const</li>
 
45
<li><div class="fn"/>bool <b><a href="qset.html#empty">empty</a></b> () const</li>
 
46
<li><div class="fn"/>const_iterator <b><a href="qset.html#end">end</a></b> () const</li>
 
47
<li><div class="fn"/>const_iterator <b><a href="qset.html#insert">insert</a></b> ( const T &amp; <i>value</i> )</li>
 
48
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#intersect">intersect</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
49
<li><div class="fn"/>bool <b><a href="qset.html#isEmpty">isEmpty</a></b> () const</li>
 
50
<li><div class="fn"/>bool <b><a href="qset.html#remove">remove</a></b> ( const T &amp; <i>value</i> )</li>
 
51
<li><div class="fn"/>void <b><a href="qset.html#reserve">reserve</a></b> ( int <i>size</i> )</li>
 
52
<li><div class="fn"/>int <b><a href="qset.html#size">size</a></b> () const</li>
 
53
<li><div class="fn"/>void <b><a href="qset.html#squeeze">squeeze</a></b> ()</li>
 
54
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#subtract">subtract</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
55
<li><div class="fn"/>QList&lt;T&gt; <b><a href="qset.html#toList">toList</a></b> () const</li>
 
56
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#unite">unite</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
57
<li><div class="fn"/>QList&lt;T&gt; <b><a href="qset.html#values">values</a></b> () const</li>
 
58
<li><div class="fn"/>bool <b><a href="qset.html#operator-not-eq">operator!=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> ) const</li>
 
59
<li><div class="fn"/>QSet&lt;T&gt; <b><a href="qset.html#operator-and">operator&amp;</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
60
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-and-eq">operator&amp;=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
61
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-and-eq-2">operator&amp;=</a></b> ( const T &amp; <i>value</i> )</li>
 
62
<li><div class="fn"/>QSet&lt;T&gt; <b><a href="qset.html#operator-2b">operator+</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
63
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-2b-eq">operator+=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
64
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-2b-eq-2">operator+=</a></b> ( const T &amp; <i>value</i> )</li>
 
65
<li><div class="fn"/>QSet&lt;T&gt; <b><a href="qset.html#operator-">operator-</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
66
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator--eq">operator-=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
67
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator--eq-2">operator-=</a></b> ( const T &amp; <i>value</i> )</li>
 
68
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-lt-lt">operator&lt;&lt;</a></b> ( const T &amp; <i>value</i> )</li>
 
69
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-eq">operator=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
70
<li><div class="fn"/>bool <b><a href="qset.html#operator-eq-eq">operator==</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> ) const</li>
 
71
<li><div class="fn"/>QSet&lt;T&gt; <b><a href="qset.html#operator-7c">operator|</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
72
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-7c-eq">operator|=</a></b> ( const QSet&lt;T&gt; &amp; <i>other</i> )</li>
 
73
<li><div class="fn"/>QSet&lt;T&gt; &amp; <b><a href="qset.html#operator-7c-eq-2">operator|=</a></b> ( const T &amp; <i>value</i> )</li>
 
74
</ul>
 
75
<a name="static-public-members"></a>
 
76
<h3>Static Public Members</h3>
 
77
<ul>
 
78
<li><div class="fn"/>QSet&lt;T&gt; <b><a href="qset.html#fromList">fromList</a></b> ( const QList&lt;T&gt; &amp; <i>list</i> )</li>
 
79
</ul>
 
80
<a name="related-non-members"></a>
 
81
<h3>Related Non-Members</h3>
 
82
<ul>
 
83
<li><div class="fn"/>QDataStream &amp; <b><a href="qset.html#operator-lt-lt-8">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QSet&lt;T&gt; &amp; <i>set</i> )</li>
 
84
<li><div class="fn"/>QDataStream &amp; <b><a href="qset.html#operator-gt-gt-8">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QSet&lt;T&gt; &amp; <i>set</i> )</li>
 
85
</ul>
 
86
<a name="details"></a>
 
87
<hr />
 
88
<h2>Detailed Description</h2>
 
89
<p>The QSet class is a template class that provides a hash-table-based set.</p>
 
90
<p>QSet&lt;T&gt; is one of Qt's generic <a href="containers.html#container-classes">container classes</a>. It stores values in an unspecified order and provides very fast lookup of the values. Internally, QSet&lt;T&gt; is implemented as a <a href="qhash.html">QHash</a>.</p>
 
91
<p>Here's an example QSet with <a href="qstring.html">QString</a> values:</p>
 
92
<pre>&nbsp;   QSet&lt;QString&gt; set;</pre>
 
93
<p>To insert a value into the set, use <a href="qset.html#insert">insert</a>():</p>
 
94
<pre>&nbsp;   set.insert(&quot;one&quot;);
 
95
    set.insert(&quot;three&quot;);
 
96
    set.insert(&quot;seven&quot;);</pre>
 
97
<p>Another way to insert items into the set is to use operator&lt;&lt;():</p>
 
98
<pre>&nbsp;   set &lt;&lt; &quot;twelve&quot; &lt;&lt; &quot;fifteen&quot; &lt;&lt; &quot;nineteen&quot;;</pre>
 
99
<p>To test whether an item belongs to the set or not, use <a href="qset.html#contains">contains</a>():</p>
 
100
<pre>&nbsp;   if (!set.contains(&quot;ninety-nine&quot;))
 
101
        ...</pre>
 
102
<p>If you want to navigate through all the values stored in a QSet, you can use an iterator. QSet supports both <a href="containers.html#java-style-iterators">Java-style iterators</a> (<a href="qsetiterator.html">QSetIterator</a>) and <a href="containers.html#stl-style-iterators">STL-style iterators</a> (<a href="qset-const-iterator.html">QSet::const_iterator</a>). Here's how to iterate over a QSet&lt;<a href="qwidget.html">QWidget</a> *&gt; using a Java-style iterator:</p>
 
103
<pre>&nbsp;   QSetIterator&lt;QWidget *&gt; i(set);
 
104
    while (i.hasNext())
 
105
        qDebug() &lt;&lt; i.next();</pre>
 
106
<p>Here's the same code, but using an STL-style iterator:</p>
 
107
<pre>&nbsp;   QSet&lt;QWidget *&gt;::const_iterator i = set.begin();
 
108
    while (i != set.end()) {
 
109
        qDebug() &lt;&lt; *i;
 
110
        ++i;
 
111
    }</pre>
 
112
<p>QSet is unordered, so an iterator's sequence cannot be assumed to be predictable. If ordering by key is required, use a <a href="qmap.html">QMap</a>.</p>
 
113
<p>To navigate through a QSet, you can also use <a href="containers.html#foreach">foreach</a>:</p>
 
114
<pre>&nbsp;   QSet&lt;QString&gt; set;
 
115
    ...
 
116
    foreach (QString value, set)
 
117
        qDebug() &lt;&lt; value;</pre>
 
118
<p>Items can be removed from the set using <a href="qset.html#remove">remove</a>(). There's also a <a href="qset.html#clear">clear</a>() function that removes all items.</p>
 
119
<p>QSet's value data type must be an <a href="containers.html#assignable-data-types">assignable data type</a>. You cannot, for example, store a <a href="qwidget.html">QWidget</a> as a value; instead, store a <a href="qwidget.html">QWidget</a> *. In addition, the type must provide <tt>operator==()</tt>, and there must also be a global <a href="qhash.html#qHashx">qHash</a>() function that returns a hash value for an argument of the key's type. See the <a href="qhash.html">QHash</a> documentation for a list of types supported by <a href="qhash.html#qHashx">qHash</a>().</p>
 
120
<p>Internally, QSet uses a hash table to perform lookups. The hash table automatically grows and shrinks to provide fast lookups without wasting too much memory. You can still control the size of the hash table by calling <a href="qset.html#reserve">reserve</a>() if you already know approximately how many elements the QSet will contain, but this isn't necessary to obtain good performance. You can also call <a href="qset.html#capacity">capacity</a>() to retrieve the hash table's size.</p>
 
121
<p>See also <a href="qsetiterator.html">QSetIterator</a>, <a href="qhash.html">QHash</a>, and <a href="qmap.html">QMap</a>.</p>
 
122
<hr />
 
123
<h2>Member Type Documentation</h2>
 
124
<h3 class="fn"><a name="ConstIterator-typedef"></a>typedef QSet::ConstIterator</h3>
 
125
<p>Qt-style synonym for <a href="qset-const-iterator.html">QSet::const_iterator</a>.</p>
 
126
<hr />
 
127
<h2>Member Function Documentation</h2>
 
128
<h3 class="fn"><a name="QSet"></a>QSet::QSet ()</h3>
 
129
<p>Constructs an empty set.</p>
 
130
<p>See also <a href="qset.html#clear">clear</a>().</p>
 
131
<h3 class="fn"><a name="QSet-2"></a>QSet::QSet ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
132
<p>Constructs a copy of <i>other</i>.</p>
 
133
<p>This operation occurs in <a href="containers.html#constant-time">constant time</a>, because <a href="qset.html">QSet</a> is <a href="shclass.html#implicitly-shared">implicitly shared</a>. This makes returning a <a href="qset.html">QSet</a> from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes <a href="containers.html#linear-time">linear time</a>.</p>
 
134
<p>See also <a href="qset.html#operator-eq">operator=</a>().</p>
 
135
<h3 class="fn"><a name="begin"></a><a href="qset-const-iterator.html">const_iterator</a> QSet::begin () const</h3>
 
136
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the set.</p>
 
137
<p>See also <a href="qset.html#end">end</a>().</p>
 
138
<h3 class="fn"><a name="capacity"></a>int QSet::capacity () const</h3>
 
139
<p>Returns the number of buckets in the <a href="qset.html">QSet</a>'s internal hash table.</p>
 
140
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qset.html">QSet</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the set, call <a href="qset.html#size">size</a>().</p>
 
141
<p>See also <a href="qset.html#reserve">reserve</a>() and <a href="qset.html#squeeze">squeeze</a>().</p>
 
142
<h3 class="fn"><a name="clear"></a>void QSet::clear ()</h3>
 
143
<p>Removes all elements from the set.</p>
 
144
<p>See also <a href="qset.html#remove">remove</a>().</p>
 
145
<h3 class="fn"><a name="constBegin"></a><a href="qset-const-iterator.html">const_iterator</a> QSet::constBegin () const</h3>
 
146
<p>Same as <a href="qset.html#begin">begin</a>(). Provided for consistency with other container classes.</p>
 
147
<p>See also <a href="qset.html#constEnd">constEnd</a>().</p>
 
148
<h3 class="fn"><a name="constEnd"></a><a href="qset-const-iterator.html">const_iterator</a> QSet::constEnd () const</h3>
 
149
<p>Same as <a href="qset.html#end">end</a>(). Provided for consistency with other container classes.</p>
 
150
<p>See also <a href="qset.html#constBegin">constBegin</a>().</p>
 
151
<h3 class="fn"><a name="contains"></a>bool QSet::contains ( const T &amp; <i>value</i> ) const</h3>
 
152
<p>Returns true if the set contains item <i>value</i>; otherwise returns false.</p>
 
153
<p>See also <a href="qset.html#insert">insert</a>() and <a href="qset.html#remove">remove</a>().</p>
 
154
<h3 class="fn"><a name="count"></a>int QSet::count () const</h3>
 
155
<p>Same as <a href="qset.html#size">size</a>().</p>
 
156
<h3 class="fn"><a name="empty"></a>bool QSet::empty () const</h3>
 
157
<p>This function is provided for STL compatibility. It is equivalent to <a href="qset.html#isEmpty">isEmpty</a>().</p>
 
158
<h3 class="fn"><a name="end"></a><a href="qset-const-iterator.html">const_iterator</a> QSet::end () const</h3>
 
159
<p>Returns a <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the set.</p>
 
160
<p>See also <a href="qset.html#begin">begin</a>().</p>
 
161
<h3 class="fn"><a name="fromList"></a>QSet&lt;T&gt; QSet::fromList ( const <a href="qlist.html">QList</a>&lt;T&gt; &amp; <i>list</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
162
<p>Returns a <a href="qset.html">QSet</a> object with the data contained in <i>list</i>. Since <a href="qset.html">QSet</a> doesn't allow duplicates, the resulting <a href="qset.html">QSet</a> might be smaller than the original <i>list</i> was.</p>
 
163
<p>Example:</p>
 
164
<pre>&nbsp;   QStringList list;
 
165
    list &lt;&lt; &quot;Julia&quot; &lt;&lt; &quot;Mike&quot; &lt;&lt; &quot;Mike&quot; &lt;&lt; &quot;Julia&quot; &lt;&lt; &quot;Julia&quot;;
 
166
 
 
167
    QSet&lt;QString&gt; set = QSet&lt;QString&gt;::fromList(list);
 
168
    set.contains(&quot;Julia&quot;);  // returns true
 
169
    set.contains(&quot;Mike&quot;);   // returns true
 
170
    set.size();             // returns 2</pre>
 
171
<p>See also <a href="qset.html#toList">toList</a>() and <a href="qlist.html#toSet">QList::toSet</a>().</p>
 
172
<h3 class="fn"><a name="insert"></a><a href="qset-const-iterator.html">const_iterator</a> QSet::insert ( const T &amp; <i>value</i> )</h3>
 
173
<p>Inserts a new item <i>value</i>. If <i>value</i> already exists in the set, nothing happens.</p>
 
174
<p>See also <a href="qset.html#operator-lt-lt">operator&lt;&lt;</a>(), <a href="qset.html#remove">remove</a>(), and <a href="qset.html#contains">contains</a>().</p>
 
175
<h3 class="fn"><a name="intersect"></a>QSet&lt;T&gt; &amp; QSet::intersect ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
176
<p>Removes any items in this set that don't exist in the <i>other</i> set.</p>
 
177
<p>See also <a href="qset.html#operator-and-eq">operator&amp;=</a>(), <a href="qset.html#unite">unite</a>(), and <a href="qset.html#subtract">subtract</a>().</p>
 
178
<h3 class="fn"><a name="isEmpty"></a>bool QSet::isEmpty () const</h3>
 
179
<p>Returns true if the set contains no elements; otherwise returns false.</p>
 
180
<p>See also <a href="qset.html#size">size</a>().</p>
 
181
<h3 class="fn"><a name="remove"></a>bool QSet::remove ( const T &amp; <i>value</i> )</h3>
 
182
<p>Removes any occurrence of item <i>value</i> from the set. Returns true if an item was actually removed; otherwise returns false.</p>
 
183
<p>See also <a href="qset.html#contains">contains</a>() and <a href="qset.html#insert">insert</a>().</p>
 
184
<h3 class="fn"><a name="reserve"></a>void QSet::reserve ( int <i>size</i> )</h3>
 
185
<p>Ensures that the <a href="qset.html">QSet</a>'s internal hash table consists of at least <i>size</i> buckets.</p>
 
186
<p>This function is useful for code that needs to build a huge set and wants to avoid repeated reallocation. For example:</p>
 
187
<pre>&nbsp;   QSet&lt;QString&gt; set;
 
188
    set.reserve(20000);
 
189
    for (int i = 0; i &lt; 20000; ++i)
 
190
        set.insert(values[i]);</pre>
 
191
<p>Ideally, <i>size</i> should be slightly more than the maximum number of elements expected in the set. <i>size</i> doesn't have to be prime, because <a href="qset.html">QSet</a> will use a prime number internally anyway. If <i>size</i> is an underestimate, the worst that will happen is that the <a href="qset.html">QSet</a> will be a bit slower.</p>
 
192
<p>In general, you will rarely ever need to call this function. <a href="qset.html">QSet</a>'s internal hash table automatically shrinks or grows to provide good performance without wasting too much memory.</p>
 
193
<p>See also <a href="qset.html#squeeze">squeeze</a>() and <a href="qset.html#capacity">capacity</a>().</p>
 
194
<h3 class="fn"><a name="size"></a>int QSet::size () const</h3>
 
195
<p>Returns the number of items in the set.</p>
 
196
<p>See also <a href="qset.html#isEmpty">isEmpty</a>() and <a href="qset.html#count">count</a>().</p>
 
197
<h3 class="fn"><a name="squeeze"></a>void QSet::squeeze ()</h3>
 
198
<p>Reduces the size of the <a href="qset.html">QSet</a>'s internal hash table to save memory.</p>
 
199
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qset.html">QSet</a>'s memory usage. In general, you will rarely ever need to call this function.</p>
 
200
<p>See also <a href="qset.html#reserve">reserve</a>() and <a href="qset.html#capacity">capacity</a>().</p>
 
201
<h3 class="fn"><a name="subtract"></a>QSet&lt;T&gt; &amp; QSet::subtract ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
202
<p>Removes all the items in the <i>other</i> set from this set.</p>
 
203
<p>See also <a href="qset.html#operator--eq">operator-=</a>(), <a href="qset.html#unite">unite</a>(), and <a href="qset.html#intersect">intersect</a>().</p>
 
204
<h3 class="fn"><a name="toList"></a><a href="qlist.html">QList</a>&lt;T&gt; QSet::toList () const</h3>
 
205
<p>Returns a <a href="qlist.html">QList</a> object with the data contained in this <a href="qset.html">QSet</a>. The order of the elements in the <a href="qlist.html">QList</a> is undefined.</p>
 
206
<p>Example:</p>
 
207
<pre>&nbsp;   QSet&lt;double&gt; set;
 
208
    set &lt;&lt; &quot;red&quot; &lt;&lt; &quot;green&quot; &lt;&lt; &quot;blue&quot; &lt;&lt; ... &lt;&lt; &quot;black&quot;;
 
209
 
 
210
    QList&lt;double&gt; list = set.toList();
 
211
    qSort(list);</pre>
 
212
<p>See also <a href="qset.html#fromList">fromList</a>(), <a href="qlist.html#fromSet">QList::fromSet</a>(), and <a href="qtalgorithms.html#qSort">qSort</a>().</p>
 
213
<h3 class="fn"><a name="unite"></a>QSet&lt;T&gt; &amp; QSet::unite ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
214
<p>Inserts all the items in the <i>other</i> set into this set.</p>
 
215
<p>See also <a href="qset.html#operator-7c-eq">operator|=</a>(), <a href="qset.html#intersect">intersect</a>(), and <a href="qset.html#subtract">subtract</a>().</p>
 
216
<h3 class="fn"><a name="values"></a><a href="qlist.html">QList</a>&lt;T&gt; QSet::values () const</h3>
 
217
<p>Returns a <a href="qlist.html">QList</a> object with the data contained in this <a href="qset.html">QSet</a>. The order of the elements in the <a href="qlist.html">QList</a> is undefined.</p>
 
218
<p>This is the same as <a href="qset.html#toList">toList</a>().</p>
 
219
<p>See also <a href="qset.html#fromList">fromList</a>(), <a href="qlist.html#fromSet">QList::fromSet</a>(), and <a href="qtalgorithms.html#qSort">qSort</a>().</p>
 
220
<h3 class="fn"><a name="operator-not-eq"></a>bool QSet::operator!= ( const QSet&lt;T&gt; &amp; <i>other</i> ) const</h3>
 
221
<p>Returns true if <i>other</i> is not equal to this set; otherwise returns false.</p>
 
222
<p>Two sets are considered equal if they contain the same elements.</p>
 
223
<p>This function requires the value type to implement <tt>operator==()</tt>.</p>
 
224
<p>See also <a href="qset.html#operator-eq-eq">operator==</a>().</p>
 
225
<h3 class="fn"><a name="operator-and"></a>QSet&lt;T&gt; QSet::operator&amp; ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
226
<p>Returns the intersection of this set and <i>other</i>.</p>
 
227
<p>See also <a href="qset.html#intersect">intersect</a>(), <a href="qset.html#operator-and-eq">operator&amp;=</a>(), <a href="qset.html#operator-7c">operator|</a>(), and <a href="qset.html#operator-">operator-</a>().</p>
 
228
<h3 class="fn"><a name="operator-and-eq"></a>QSet&lt;T&gt; &amp; QSet::operator&amp;= ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
229
<p>Syntactic sugar for intersect(<i>other</i>).</p>
 
230
<p>See also <a href="qset.html#operator-and">operator&amp;</a>(), <a href="qset.html#operator-7c-eq">operator|=</a>(), and <a href="qset.html#operator--eq">operator-=</a>().</p>
 
231
<h3 class="fn"><a name="operator-and-eq-2"></a>QSet&lt;T&gt; &amp; QSet::operator&amp;= ( const T &amp; <i>value</i> )</h3>
 
232
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
233
<p>Syntactic sugar for intersect(<i>other</i>), with <i>other</i> being a set that only contains <i>value</i>.</p>
 
234
<h3 class="fn"><a name="operator-2b"></a>QSet&lt;T&gt; QSet::operator+ ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
235
<p>Returns the union of this set and <i>other</i>.</p>
 
236
<p>See also <a href="qset.html#unite">unite</a>(), <a href="qset.html#operator-7c-eq">operator|=</a>(), <a href="qset.html#operator-and">operator&amp;</a>(), and <a href="qset.html#operator-">operator-</a>().</p>
 
237
<h3 class="fn"><a name="operator-2b-eq"></a>QSet&lt;T&gt; &amp; QSet::operator+= ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
238
<p>Syntactic sugar for unite(<i>other</i>).</p>
 
239
<p>See also <a href="qset.html#operator-7c">operator|</a>(), <a href="qset.html#operator-and-eq">operator&amp;=</a>(), and <a href="qset.html#operator--eq">operator-=</a>().</p>
 
240
<h3 class="fn"><a name="operator-2b-eq-2"></a>QSet&lt;T&gt; &amp; QSet::operator+= ( const T &amp; <i>value</i> )</h3>
 
241
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
242
<p>Inserts a new item <i>value</i> and returns a reference to this set. If <i>value</i> already exists in the set, the set is left unchanged.</p>
 
243
<p>See also <a href="qset.html#insert">insert</a>().</p>
 
244
<h3 class="fn"><a name="operator-"></a>QSet&lt;T&gt; QSet::operator- ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
245
<p>Returns the set difference of this set with <i>other</i>.</p>
 
246
<p>See also <a href="qset.html#subtract">subtract</a>(), <a href="qset.html#operator--eq">operator-=</a>(), <a href="qset.html#operator-7c">operator|</a>(), and <a href="qset.html#operator-and">operator&amp;</a>().</p>
 
247
<h3 class="fn"><a name="operator--eq"></a>QSet&lt;T&gt; &amp; QSet::operator-= ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
248
<p>Syntactic sugar for subtract(<i>other</i>).</p>
 
249
<p>See also <a href="qset.html#operator-">operator-</a>(), <a href="qset.html#operator-7c-eq">operator|=</a>(), and <a href="qset.html#operator-and-eq">operator&amp;=</a>().</p>
 
250
<h3 class="fn"><a name="operator--eq-2"></a>QSet&lt;T&gt; &amp; QSet::operator-= ( const T &amp; <i>value</i> )</h3>
 
251
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
252
<p>Removes any occurrence of item <i>value</i> from the set and returns a reference to this set. If <i>value</i> didn't exist in the set, the set is left unchanged.</p>
 
253
<p>See also <a href="qset.html#remove">remove</a>().</p>
 
254
<h3 class="fn"><a name="operator-lt-lt"></a>QSet&lt;T&gt; &amp; QSet::operator&lt;&lt; ( const T &amp; <i>value</i> )</h3>
 
255
<p>Inserts a new item <i>value</i> and returns a reference to this set. If <i>value</i> already exists in the set, the set is left unchanged.</p>
 
256
<p>See also <a href="qset.html#insert">insert</a>().</p>
 
257
<h3 class="fn"><a name="operator-eq"></a>QSet&lt;T&gt; &amp; QSet::operator= ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
258
<p>Assigns <i>other</i> to this set and returns a reference to this set.</p>
 
259
<h3 class="fn"><a name="operator-eq-eq"></a>bool QSet::operator== ( const QSet&lt;T&gt; &amp; <i>other</i> ) const</h3>
 
260
<p>Returns true if <i>other</i> is equal to this set; otherwise returns false.</p>
 
261
<p>Two sets are considered equal if they contain the same elements.</p>
 
262
<p>This function requires the value type to implement <tt>operator==()</tt>.</p>
 
263
<p>See also <a href="qset.html#operator-not-eq">operator!=</a>().</p>
 
264
<h3 class="fn"><a name="operator-7c"></a>QSet&lt;T&gt; QSet::operator| ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
265
<p>Returns the union of this set and <i>other</i>.</p>
 
266
<p>See also <a href="qset.html#unite">unite</a>(), <a href="qset.html#operator-7c-eq">operator|=</a>(), <a href="qset.html#operator-and">operator&amp;</a>(), and <a href="qset.html#operator-">operator-</a>().</p>
 
267
<h3 class="fn"><a name="operator-7c-eq"></a>QSet&lt;T&gt; &amp; QSet::operator|= ( const QSet&lt;T&gt; &amp; <i>other</i> )</h3>
 
268
<p>Syntactic sugar for unite(<i>other</i>).</p>
 
269
<p>See also <a href="qset.html#operator-7c">operator|</a>(), <a href="qset.html#operator-and-eq">operator&amp;=</a>(), and <a href="qset.html#operator--eq">operator-=</a>().</p>
 
270
<h3 class="fn"><a name="operator-7c-eq-2"></a>QSet&lt;T&gt; &amp; QSet::operator|= ( const T &amp; <i>value</i> )</h3>
 
271
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
272
<p>Inserts a new item <i>value</i> and returns a reference to this set. If <i>value</i> already exists in the set, the set is left unchanged.</p>
 
273
<p>See also <a href="qset.html#insert">insert</a>().</p>
 
274
<hr />
 
275
<h2>Related Non-Members</h2>
 
276
<h3 class="fn"><a name="operator-lt-lt-8"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QSet&lt;T&gt; &amp; <i>set</i> )</h3>
 
277
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
278
<p>Writes the set <i>set</i> to stream <i>out</i>.</p>
 
279
<p>This function requires the value type to implement <tt>operator&lt;&lt;()</tt>.</p>
 
280
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
281
<h3 class="fn"><a name="operator-gt-gt-8"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QSet&lt;T&gt; &amp; <i>set</i> )</h3>
 
282
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
283
<p>Reads a set from stream <i>in</i> into <i>set</i>.</p>
 
284
<p>This function requires the value type to implement <tt>operator&gt;&gt;()</tt>.</p>
 
285
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
286
<p /><address><hr /><div align="center">
 
287
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
288
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
289
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
290
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
291
</tr></table></div></address></body>
 
292
</html>