File: qbitarray.html

package info (click to toggle)
qt-x11 3%3A2.3.1-22
  • links: PTS
  • area: main
  • in suites: woody
  • size: 48,524 kB
  • ctags: 46,337
  • sloc: cpp: 260,077; ansic: 32,457; makefile: 31,131; yacc: 2,444; sh: 1,513; lex: 480; perl: 422; xml: 68; lisp: 15
file content (253 lines) | stat: -rw-r--r-- 14,810 bytes parent folder | download | duplicates (2)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QBitArray Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QBitArray Class Reference</h1><br clear="all">
<p>
The QBitArray class provides an array of bits.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qbitarray-h.html">qbitarray.h</a>&gt;</code>
<p>
Inherits <a href="qbytearray.html">QByteArray</a>.
<p><a href="qbitarray-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#e533fe"><b>QBitArray</b></a>()</div>
<li><div class="fn"><a href="#823ee1"><b>QBitArray</b></a>(uintsize)</div>
<li><div class="fn"><a href="#fe832a"><b>QBitArray</b></a>(constQBitArray&amp;a)</div>
<li><div class="fn">QBitArray&amp;<a href="#5e1a4d"><b>operator=</b></a>(constQBitArray&amp;)</div>
<li><div class="fn">uint<a href="#cb21b3"><b>size</b></a>()const</div>
<li><div class="fn">bool<a href="#cd56bd"><b>resize</b></a>(uintsize)</div>
<li><div class="fn">bool<a href="#3c8d5b"><b>fill</b></a>(boolv, intsize=-1)</div>
<li><div class="fn">virtualvoid<a href="#54f3d7"><b>detach</b></a>()</div>
<li><div class="fn">QBitArray<a href="#074e11"><b>copy</b></a>()const</div>
<li><div class="fn">bool<a href="#fbcada"><b>testBit</b></a>(uintindex)const</div>
<li><div class="fn">void<a href="#2775cb"><b>setBit</b></a>(uintindex)</div>
<li><div class="fn">void<a href="#faf6b7"><b>setBit</b></a>(uintindex, boolvalue)</div>
<li><div class="fn">void<a href="#809f09"><b>clearBit</b></a>(uintindex)</div>
<li><div class="fn">bool<a href="#d40857"><b>toggleBit</b></a>(uintindex)</div>
<li><div class="fn">bool<a href="#7d94e3"><b>at</b></a>(uintindex)const</div>
<li><div class="fn">QBitVal<a href="#988b5d"><b>operator[]</b></a>(intindex)</div>
<li><div class="fn">bool<a href="#1821b0"><b>operator[]</b></a>(intindex)const</div>
<li><div class="fn">QBitArray&amp;<a href="#142428"><b>operator&amp;=</b></a>(constQBitArray&amp;)</div>
<li><div class="fn">QBitArray&amp;<a href="#b9e8fa"><b>operator|=</b></a>(constQBitArray&amp;)</div>
<li><div class="fn">QBitArray&amp;<a href="#3e519c"><b>operator^=</b></a>(constQBitArray&amp;)</div>
<li><div class="fn">QBitArray<a href="#05abdf"><b>operator~</b></a>()const</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">array_data*<b>newData</b>()</div>
<li><div class="fn">virtualvoid<a href="#cfc164"><b>deleteData</b></a>(array_data*d)</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QBitArray <a href="qbitarray.html#11dcc0"><b>operator^</b></a> (const QBitArray &amp; a1, const QBitArray &amp; a2)
<li>QBitArray <a href="qbitarray.html#3b8a87"><b>operator&amp;</b></a> (const QBitArray &amp; a1, const QBitArray &amp; a2)
<li>QDataStream &amp; <a href="qbitarray.html#cbf466"><b>operator&lt;&lt;</b></a> (QDataStream &amp; s, const QBitArray &amp; a)
<li>QBitArray <a href="qbitarray.html#cdfb18"><b>operator|</b></a> (const QBitArray &amp; a1, const QBitArray &amp; a2)
<li>QDataStream &amp; <a href="qbitarray.html#d17d77"><b>operator&gt;&gt;</b></a> (QDataStream &amp; s, QBitArray &amp; a)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QBitArray class provides an array of bits.
<p>
<a href="qstring.html">QString</a> inherits <a href="qbytearray.html">QByteArray</a>, which is defined as <a href="qarray.html">QArray</a>&lt;char&gt;.
<p>Since QBitArray is a QArray, it uses explicit
<a href="shclass.html">sharing</a> with a reference count.
<p>A QBitArray is a special byte array that can access individual bits and
perform bit-operations (AND, OR, XOR and NOT) on entire arrays or bits.
<p>Bits can be manipulated by the <a href="#2775cb">setBit</a>() and <a href="#809f09">clearBit</a>() functions, but it
is also possible to use the indexing [] operator to test and set
individual bits. The [] operator is a little slower than the others,
because some tricks are required to implement single-bit assignments.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a(3);
    a.<a href="#2775cb">setBit</a>( 0 );
    a.<a href="#809f09">clearBit</a>( 1 );
    a.<a href="#2775cb">setBit</a>( 2 );                      // a = [1 0 1]

    <a href="qbitarray.html">QBitArray</a> b(3);
    b[0] = 1;
    b[1] = 1;
    b[2] = 0;                           // b = [1 1 0]

    <a href="qbitarray.html">QBitArray</a> c;
    c = ~a &amp; b;                         // c = [0 1 0]
</pre>

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="e533fe"></a>QBitArray::QBitArray()</h3>
<p>Constructs an empty bit array.
<h3 class="fn"><a name="fe832a"></a>QBitArray::QBitArray(constQBitArray&amp;a)</h3>
<p>Constructs a shallow copy of <em>a.</em>
<h3 class="fn"><a name="823ee1"></a>QBitArray::QBitArray(uintsize)</h3>
<p>Constructs a bit array of <em>size</em> bits. The bits are uninitialized.
<h3 class="fn">bool<a name="7d94e3"></a>QBitArray::at(uintindex)const</h3>
<p>Returns the value (0 or 1) of the bit at position <em>index.</em>
<p>See also  <a href="#1821b0">operator[]</a>().
<h3 class="fn">void<a name="809f09"></a>QBitArray::clearBit(uintindex)</h3>
<p>Clears the bit at position <em>index</em> (sets it to 0).
<p>See also  <a href="#2775cb">setBit</a>() and <a href="#d40857">toggleBit</a>().
<h3 class="fn">QBitArray<a name="074e11"></a>QBitArray::copy()const</h3>
<p>Returns a deep copy of the bit array.
<p>See also  <a href="#54f3d7">detach</a>().
<h3 class="fn">void<a name="cfc164"></a>QBitArray::deleteData(<a href="qbitarray.html#array_data">array_data</a>*d) <code>[virtualprotected]</code></h3>
<p>Deletes data specific to QBitArray that extended what <a href="qgarray.html">QGArray</a> provided.
<p>Reimplemented from <a href="qgarray.html#c19613">QGArray.</a>
<h3 class="fn">void<a name="54f3d7"></a>QBitArray::detach() <code>[virtual]</code></h3>
<p>Detaches from shared bit array data and makes sure that this bit array
is the only one referring the data.
<p>If multiple bit arrays share common data, this bit array dereferences the
data and gets a copy of the data. Nothing will be done if there is just
a single reference.
<p>See also  <a href="#074e11">copy</a>().
<p>Reimplemented from <a href="qgarray.html#9b33f3">QGArray.</a>
<h3 class="fn">bool<a name="3c8d5b"></a>QBitArray::fill(boolv, intsize=-1)</h3>
<p>Fills the bit array with <em>v</em> (1's if <em>v</em> is TRUE, or 0's if <em>v</em> is FALSE).
<p>Will resize the bit array to <em>size</em> bits if <em>size</em> is nonnegative.
<p>Returns FALSE if a nonnegative <em>size</em> was specified and if the bit array
could not be resized, otherwise returns TRUE.
<p>See also  <a href="#cd56bd">resize</a>().
<h3 class="fn">QBitArray&amp;<a name="142428"></a>QBitArray::operator&amp;=(constQBitArray&amp;a)</h3>
<p>Performs the AND operation between all bits in this bit array and <em>a.</em>
Returns a reference to this bit array.
<p>The result has the length of the longest bit array of the two, with the bits
missing from the shortest array taken as 0.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a( 3 ), b( 2 );
    a[0] = 1;  a[1] = 0;  a[2] = 1;     // a = [1 0 1]
    b[0] = 1;  b[1] = 0;                // b = [1 0]
    a &amp;= b;                             // a = [1 0 0]
</pre>
<p>See also  <a href="#b9e8fa">operator|=</a>(), <a href="#3e519c">operator^=</a>() and <a href="#05abdf">operator~</a>().
<h3 class="fn">QBitArray&amp;<a name="5e1a4d"></a>QBitArray::operator=(constQBitArray&amp;a)</h3>
<p>Assigns a shallow copy of <em>a</em> to this bit array and returns a reference
to this array.
<h3 class="fn"><a href="qbitval.html">QBitVal</a><a name="988b5d"></a>QBitArray::operator[](intindex)</h3>
<p>Implements the [] operator for bit arrays.
<p>The returned <a href="qbitval.html">QBitVal</a> is a context object. It makes it possible to get
and set a single bit value.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a( 3 );
    a[0] = 0;
    a[1] = 1;
    a[2] = a[0] ^ a[1];
</pre>
<p>The functions <a href="#fbcada">testBit</a>(), <a href="#2775cb">setBit</a>() and <a href="#809f09">clearBit</a>() are faster.
<p>See also  <a href="#7d94e3">at</a>().
<h3 class="fn">bool<a name="1821b0"></a>QBitArray::operator[](intindex)const</h3>
<p>Implements the [] operator for constant bit arrays.
<h3 class="fn">QBitArray&amp;<a name="3e519c"></a>QBitArray::operator^=(constQBitArray&amp;a)</h3>
<p>Performs the XOR operation between all bits in this bit array and <em>a.</em>
Returns a reference to this bit array.
<p>The result has the length of the longest bit array of the two, with the bits
missing from the shortest array taken as 0.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a( 3 ), b( 2 );
    a[0] = 1;  a[1] = 0;  a[2] = 1;     // a = [1 0 1]
    b[0] = 1;  b[1] = 0;                // b = [1 0]
    a ^= b;                             // a = [0 0 1]
</pre>
<p>See also  <a href="#142428">operator&amp;=</a>(), <a href="#b9e8fa">operator|=</a>() and <a href="#05abdf">operator~</a>().
<h3 class="fn">QBitArray&amp;<a name="b9e8fa"></a>QBitArray::operator|=(constQBitArray&amp;a)</h3>
<p>Performs the OR operation between all bits in this bit array and <em>a.</em>
Returns a reference to this bit array.
<p>The result has the length of the longest bit array of the two, with the bits
missing from the shortest array taken as 0.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a( 3 ), b( 2 );
    a[0] = 1;  a[1] = 0;  a[2] = 1;     // a = [1 0 1]
    b[0] = 1;  b[1] = 0;                // b = [1 0]
    a |= b;                             // a = [1 0 1]
</pre>
<p>See also  <a href="#142428">operator&amp;=</a>(), <a href="#3e519c">operator^=</a>() and <a href="#05abdf">operator~</a>().
<h3 class="fn">QBitArray<a name="05abdf"></a>QBitArray::operator~()const</h3>
<p>Returns a bit array which contains the inverted bits of this bit array.
<p>Example:
<pre>    <a href="qbitarray.html">QBitArray</a> a( 3 ), b;
    a[0] = 1;  a[1] = 0; a[2] = 1;      // a = [1 0 1]
    b = ~a;                             // b = [0 1 0]
</pre>
<h3 class="fn">bool<a name="cd56bd"></a>QBitArray::resize(uintsize)</h3>
<p>Resizes the bit array to <em>size</em> bits.
Returns TRUE if the bit array could be resized.
<p>When expanding the bit array, the new bits will be uninitialized.
<p>See also  <a href="#cb21b3">size</a>().
<h3 class="fn">void<a name="2775cb"></a>QBitArray::setBit(uintindex)</h3>
<p>Sets the bit at position <em>index</em> (sets it to 1).
<p>See also  <a href="#809f09">clearBit</a>() and <a href="#d40857">toggleBit</a>().
<h3 class="fn">void<a name="faf6b7"></a>QBitArray::setBit(uintindex, boolvalue)</h3>
<p>Sets the bit at position <em>index</em> to <em>value.</em>
<p>Equivalent to:
<pre>    if ( value )
        setBit( index );
    else
        clearBit( index );
</pre>
<p>See also  <a href="#809f09">clearBit</a>() and <a href="#d40857">toggleBit</a>().
<h3 class="fn">uint<a name="cb21b3"></a>QBitArray::size()const</h3>
<p>Returns the size (number of bits) of the bit array.
<p>See also  <a href="#cd56bd">resize</a>().
<h3 class="fn">bool<a name="fbcada"></a>QBitArray::testBit(uintindex)const</h3>
<p>Returns TRUE if the bit at position <em>index</em> is set.
<p>See also  <a href="#2775cb">setBit</a>() and <a href="#809f09">clearBit</a>().
<h3 class="fn">bool<a name="d40857"></a>QBitArray::toggleBit(uintindex)</h3>
<p>Toggles the bit at position <em>index.</em>
<p>If the previous value was 0, the new value will be 1.  If the previous
value was 1, the new value will be 0.
<p>See also  <a href="#2775cb">setBit</a>() and <a href="#809f09">clearBit</a>().
<hr><h2>Related Functions</h2>
<h3>QBitArray <a name="11dcc0"></a>operator^ (const QBitArray &amp; a1, const QBitArray &amp; a2)</h3>
<p>Returns the XOR result between the bit arrays <em>a1</em> and <em>a2.</em>
<p>See also  QBitArray::operator^().

<h3>QBitArray <a name="3b8a87"></a>operator&amp; (const QBitArray &amp; a1, const QBitArray &amp; a2)</h3>
<p>Returns the AND result between the bit arrays <em>a1</em> and <em>a2.</em>
<p>See also  QBitArray::operator&=().

<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="cbf466"></a>operator&lt;&lt; (<a href="qdatastream.html">QDataStream</a> &amp; s, const QBitArray &amp; a)</h3>
<p>Writes a bit array to a stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<h3>QBitArray <a name="cdfb18"></a>operator| (const QBitArray &amp; a1, const QBitArray &amp; a2)</h3>
<p>Returns the OR result between the bit arrays <em>a1</em> and <em>a2.</em>
<p>See also  QBitArray::operator|=().

<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="d17d77"></a>operator&gt;&gt; (<a href="qdatastream.html">QDataStream</a> &amp; s, QBitArray &amp; a)</h3>
<p>Reads a bit array from a stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.1"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2000
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>