1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>BitMagic: bm::bvector< Alloc, MS >::reference Class Reference</title>
3
<title>BitMagic: sample5.cpp</title>
4
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
6
6
<!-- Generated by Doxygen 1.4.1 -->
7
7
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="examples.html">Examples</a></div>
9
<a class="el" href="a00092.html">bm</a>::<a class="el" href="a00048.html">bvector</a>::<a class="el" href="a00056.html">reference</a></div>
10
<h1>bm::bvector< Alloc, MS >::reference Class Reference<br>
12
[<a class="el" href="a00095.html">The Main bvector<> Group</a>]</small>
13
</h1>Class reference implements an object for bit assignment. Since C++ does not provide with build-in bit type supporting l-value operations we have to emulate it.
14
<a href="#_details">More...</a>
16
<code>#include <<a class="el" href="a00102.html">bm.h</a>></code>
18
<table border="0" cellpadding="0" cellspacing="0">
20
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
21
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a0">reference</a> (<a class="el" href="a00048.html">bvector</a>< Alloc, MS > &bv, <a class="el" href="a00092.html#a9">bm::id_t</a> position)</td></tr>
23
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a1">reference</a> (const <a class="el" href="a00056.html">reference</a> &ref)</td></tr>
25
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a2">operator bool</a> () const </td></tr>
27
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a3">operator=</a> (const <a class="el" href="a00056.html">reference</a> &ref) const </td></tr>
29
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a4">operator=</a> (bool value) const </td></tr>
31
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a5">operator==</a> (const <a class="el" href="a00056.html">reference</a> &ref) const </td></tr>
33
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a6">operator &=</a> (bool value) const </td></tr>
35
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a7">operator|=</a> (bool value) const </td></tr>
37
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a8">operator^=</a> (bool value) const </td></tr>
39
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a9">operator!</a> () const </td></tr>
41
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a10">operator~</a> () const </td></tr>
43
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00056.html">reference</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a11">flip</a> ()</td></tr>
46
<hr><a name="_details"></a><h2>Detailed Description</h2>
47
<h3>template<class Alloc, class MS><br>
48
class bm::bvector< Alloc, MS >::reference</h3>
50
Class reference implements an object for bit assignment. Since C++ does not provide with build-in bit type supporting l-value operations we have to emulate it.
54
Definition at line <a class="el" href="a00102.html#l00144">144</a> of file <a class="el" href="a00102.html">bm.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
55
<a class="anchor" name="a0" doxytag="bm::bvector::reference::reference"></a><p>
56
<table class="mdTable" cellpadding="2" cellspacing="0">
59
<table cellpadding="0" cellspacing="0" border="0">
61
<td class="mdPrefix" colspan="4">
62
template<class Alloc, class MS> </td>
65
<td class="md" nowrap valign="top"><a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::reference </td>
66
<td class="md" valign="top">( </td>
67
<td class="md" nowrap valign="top"><a class="el" href="a00048.html">bvector</a>< Alloc, MS > & </td>
68
<td class="mdname" nowrap> <em>bv</em>, </td>
71
<td class="md" nowrap align="right"></td>
73
<td class="md" nowrap><a class="el" href="a00092.html#a9">bm::id_t</a> </td>
74
<td class="mdname" nowrap> <em>position</em></td>
78
<td class="md">) </td>
79
<td class="md" colspan="2"><code> [inline]</code></td>
85
<table cellspacing="5" cellpadding="0" border="0">
95
Definition at line <a class="el" href="a00102.html#l00147">147</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
98
<a class="anchor" name="a1" doxytag="bm::bvector::reference::reference"></a><p>
99
<table class="mdTable" cellpadding="2" cellspacing="0">
102
<table cellpadding="0" cellspacing="0" border="0">
104
<td class="mdPrefix" colspan="4">
105
template<class Alloc, class MS> </td>
108
<td class="md" nowrap valign="top"><a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::reference </td>
109
<td class="md" valign="top">( </td>
110
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a> & </td>
111
<td class="mdname1" valign="top" nowrap> <em>ref</em> </td>
112
<td class="md" valign="top"> ) </td>
113
<td class="md" nowrap><code> [inline]</code></td>
119
<table cellspacing="5" cellpadding="0" border="0">
129
Definition at line <a class="el" href="a00102.html#l00152">152</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
132
<hr><h2>Member Function Documentation</h2>
133
<a class="anchor" name="a11" doxytag="bm::bvector::reference::flip"></a><p>
134
<table class="mdTable" cellpadding="2" cellspacing="0">
137
<table cellpadding="0" cellspacing="0" border="0">
139
<td class="mdPrefix" colspan="4">
140
template<class Alloc, class MS> </td>
143
<td class="md" nowrap valign="top"><a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::flip </td>
144
<td class="md" valign="top">( </td>
145
<td class="mdname1" valign="top" nowrap> </td>
146
<td class="md" valign="top"> ) </td>
147
<td class="md" nowrap><code> [inline]</code></td>
153
<table cellspacing="5" cellpadding="0" border="0">
161
Negates the bit value
163
Definition at line <a class="el" href="a00102.html#l00218">218</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
166
<a class="anchor" name="a6" doxytag="bm::bvector::reference::operator &="></a><p>
167
<table class="mdTable" cellpadding="2" cellspacing="0">
170
<table cellpadding="0" cellspacing="0" border="0">
172
<td class="mdPrefix" colspan="4">
173
template<class Alloc, class MS> </td>
176
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator &= </td>
177
<td class="md" valign="top">( </td>
178
<td class="md" nowrap valign="top">bool </td>
179
<td class="mdname1" valign="top" nowrap> <em>value</em> </td>
180
<td class="md" valign="top"> ) </td>
181
<td class="md" nowrap> const<code> [inline]</code></td>
187
<table cellspacing="5" cellpadding="0" border="0">
195
Bitwise AND. Performs operation: bit = bit AND value
197
Definition at line <a class="el" href="a00102.html#l00182">182</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
200
<a class="anchor" name="a2" doxytag="bm::bvector::reference::operator bool"></a><p>
201
<table class="mdTable" cellpadding="2" cellspacing="0">
204
<table cellpadding="0" cellspacing="0" border="0">
206
<td class="mdPrefix" colspan="4">
207
template<class Alloc, class MS> </td>
210
<td class="md" nowrap valign="top"><a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator bool </td>
211
<td class="md" valign="top">( </td>
212
<td class="mdname1" valign="top" nowrap> </td>
213
<td class="md" valign="top"> ) </td>
214
<td class="md" nowrap> const<code> [inline]</code></td>
220
<table cellspacing="5" cellpadding="0" border="0">
230
Definition at line <a class="el" href="a00102.html#l00159">159</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
233
<a class="anchor" name="a9" doxytag="bm::bvector::reference::operator!"></a><p>
234
<table class="mdTable" cellpadding="2" cellspacing="0">
237
<table cellpadding="0" cellspacing="0" border="0">
239
<td class="mdPrefix" colspan="4">
240
template<class Alloc, class MS> </td>
243
<td class="md" nowrap valign="top">bool <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator! </td>
244
<td class="md" valign="top">( </td>
245
<td class="mdname1" valign="top" nowrap> </td>
246
<td class="md" valign="top"> ) </td>
247
<td class="md" nowrap> const<code> [inline]</code></td>
253
<table cellspacing="5" cellpadding="0" border="0">
263
Definition at line <a class="el" href="a00102.html#l00206">206</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
266
<a class="anchor" name="a4" doxytag="bm::bvector::reference::operator="></a><p>
267
<table class="mdTable" cellpadding="2" cellspacing="0">
270
<table cellpadding="0" cellspacing="0" border="0">
272
<td class="mdPrefix" colspan="4">
273
template<class Alloc, class MS> </td>
276
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator= </td>
277
<td class="md" valign="top">( </td>
278
<td class="md" nowrap valign="top">bool </td>
279
<td class="mdname1" valign="top" nowrap> <em>value</em> </td>
280
<td class="md" valign="top"> ) </td>
281
<td class="md" nowrap> const<code> [inline]</code></td>
287
<table cellspacing="5" cellpadding="0" border="0">
297
Definition at line <a class="el" href="a00102.html#l00170">170</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
300
<a class="anchor" name="a3" doxytag="bm::bvector::reference::operator="></a><p>
301
<table class="mdTable" cellpadding="2" cellspacing="0">
304
<table cellpadding="0" cellspacing="0" border="0">
306
<td class="mdPrefix" colspan="4">
307
template<class Alloc, class MS> </td>
310
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator= </td>
311
<td class="md" valign="top">( </td>
312
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a> & </td>
313
<td class="mdname1" valign="top" nowrap> <em>ref</em> </td>
314
<td class="md" valign="top"> ) </td>
315
<td class="md" nowrap> const<code> [inline]</code></td>
321
<table cellspacing="5" cellpadding="0" border="0">
331
Definition at line <a class="el" href="a00102.html#l00164">164</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
334
<a class="anchor" name="a5" doxytag="bm::bvector::reference::operator=="></a><p>
335
<table class="mdTable" cellpadding="2" cellspacing="0">
338
<table cellpadding="0" cellspacing="0" border="0">
340
<td class="mdPrefix" colspan="4">
341
template<class Alloc, class MS> </td>
344
<td class="md" nowrap valign="top">bool <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator== </td>
345
<td class="md" valign="top">( </td>
346
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a> & </td>
347
<td class="mdname1" valign="top" nowrap> <em>ref</em> </td>
348
<td class="md" valign="top"> ) </td>
349
<td class="md" nowrap> const<code> [inline]</code></td>
355
<table cellspacing="5" cellpadding="0" border="0">
365
Definition at line <a class="el" href="a00102.html#l00176">176</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
368
<a class="anchor" name="a8" doxytag="bm::bvector::reference::operator^="></a><p>
369
<table class="mdTable" cellpadding="2" cellspacing="0">
372
<table cellpadding="0" cellspacing="0" border="0">
374
<td class="mdPrefix" colspan="4">
375
template<class Alloc, class MS> </td>
378
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator^= </td>
379
<td class="md" valign="top">( </td>
380
<td class="md" nowrap valign="top">bool </td>
381
<td class="mdname1" valign="top" nowrap> <em>value</em> </td>
382
<td class="md" valign="top"> ) </td>
383
<td class="md" nowrap> const<code> [inline]</code></td>
389
<table cellspacing="5" cellpadding="0" border="0">
397
Bitwise exclusive-OR (XOR). Performs operation: bit = bit XOR value
399
Definition at line <a class="el" href="a00102.html#l00199">199</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
402
<a class="anchor" name="a7" doxytag="bm::bvector::reference::operator|="></a><p>
403
<table class="mdTable" cellpadding="2" cellspacing="0">
406
<table cellpadding="0" cellspacing="0" border="0">
408
<td class="mdPrefix" colspan="4">
409
template<class Alloc, class MS> </td>
412
<td class="md" nowrap valign="top">const <a class="el" href="a00056.html">reference</a>& <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator|= </td>
413
<td class="md" valign="top">( </td>
414
<td class="md" nowrap valign="top">bool </td>
415
<td class="mdname1" valign="top" nowrap> <em>value</em> </td>
416
<td class="md" valign="top"> ) </td>
417
<td class="md" nowrap> const<code> [inline]</code></td>
423
<table cellspacing="5" cellpadding="0" border="0">
431
Bitwise OR. Performs operation: bit = bit OR value
433
Definition at line <a class="el" href="a00102.html#l00189">189</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
436
<a class="anchor" name="a10" doxytag="bm::bvector::reference::operator~"></a><p>
437
<table class="mdTable" cellpadding="2" cellspacing="0">
440
<table cellpadding="0" cellspacing="0" border="0">
442
<td class="mdPrefix" colspan="4">
443
template<class Alloc, class MS> </td>
446
<td class="md" nowrap valign="top">bool <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::reference::operator~ </td>
447
<td class="md" valign="top">( </td>
448
<td class="mdname1" valign="top" nowrap> </td>
449
<td class="md" valign="top"> ) </td>
450
<td class="md" nowrap> const<code> [inline]</code></td>
456
<table cellspacing="5" cellpadding="0" border="0">
466
Definition at line <a class="el" href="a00102.html#l00212">212</a> of file <a class="el" href="a00102.html">bm.h</a>. </td>
469
<hr>The documentation for this class was generated from the following file:<ul>
470
<li><a class="el" href="a00102.html">bm.h</a></ul>
471
<hr size="1"><address style="align: right;"><small>Generated on Thu Apr 20 13:29:15 2006 for BitMagic by
8
<h1>sample5.cpp</h1>Example demonstrates using enumerators - the fastest way to retrieve indexes of 1 bits from the bitvector. This approach works faster than get_first/get_next functions.<p>
9
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00084.html#n1">bm::bvector<>::enumerator</a></dd></dl>
10
For more information please visit: <a href="http://bmagic.sourceforge.net">http://bmagic.sourceforge.net</a><p>
11
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
12
<span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
13
<span class="comment"></span>
14
<span class="comment">Permission is hereby granted, free of charge, to any person </span>
15
<span class="comment">obtaining a copy of this software and associated documentation </span>
16
<span class="comment">files (the "Software"), to deal in the Software without restriction, </span>
17
<span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
18
<span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
19
<span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
20
<span class="comment">subject to the following conditions:</span>
21
<span class="comment"></span>
22
<span class="comment">The above copyright notice and this permission notice shall be included </span>
23
<span class="comment">in all copies or substantial portions of the Software.</span>
24
<span class="comment"></span>
25
<span class="comment">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, </span>
26
<span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
27
<span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
28
<span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
29
<span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
30
<span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
31
<span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
32
<span class="comment">*/</span>
33
<span class="comment"></span>
34
<span class="comment">/** \example sample5.cpp</span>
35
<span class="comment"> Example demonstrates using enumerators - the fastest way to retrieve </span>
36
<span class="comment"> indexes of 1 bits from the bitvector. This approach works faster than</span>
37
<span class="comment"> get_first/get_next functions.</span>
38
<span class="comment"> </span>
39
<span class="comment"> \sa bm::bvector<>::enumerator </span>
40
<span class="comment"></span>
41
<span class="comment">For more information please visit: http://bmagic.sourceforge.net</span>
42
<span class="comment"></span>
43
<span class="comment">*/</span>
45
<span class="preprocessor">#include <iostream></span>
46
<span class="preprocessor">#include <algorithm></span>
47
<span class="preprocessor">#include "<a class="code" href="a00111.html">bm.h</a>"</span>
49
<span class="keyword">using</span> <span class="keyword">namespace </span>std;
51
<span class="keywordtype">void</span> <a name="a28"></a><a class="code" href="a00124.html#a0">Print</a>(<span class="keywordtype">unsigned</span> n)
53
cout << n << endl;;
56
<span class="keywordtype">int</span> <a name="a29"></a><a class="code" href="a00120.html#a0">main</a>(<span class="keywordtype">void</span>)
58
<a name="_a30"></a><a class="code" href="a00084.html">bm::bvector<></a> bv;
60
bv[10] = <span class="keyword">true</span>;
61
bv[100] = <span class="keyword">true</span>;
62
bv[10000] = <span class="keyword">true</span>;
64
<a class="code" href="a00084.html">bm::bvector<></a>::enumerator en = bv.<a name="a31"></a><a class="code" href="a00084.html#a61">first</a>();
65
<a class="code" href="a00084.html">bm::bvector<></a>::enumerator en_end = bv.<a name="a32"></a><a class="code" href="a00084.html#a62">end</a>();
67
<span class="keywordflow">while</span> (en < en_end)
69
cout << *en << endl;
70
++en; <span class="comment">// Fastest way to increment enumerator</span>
73
en = bv.<a class="code" href="a00084.html#a61">first</a>();
75
<span class="comment">// This is not the fastest way to do the job, because for_each </span>
76
<span class="comment">// often will try to calculate difference between iterators,</span>
77
<span class="comment">// which is expensive for enumerators.</span>
78
<span class="comment">// But it can be useful for some STL loyal applications. </span>
80
std::for_each(en, en_end, Print);
82
<span class="keywordflow">return</span> 0;
84
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:25 2007 for BitMagic by
472
85
<a href="http://www.doxygen.org/index.html">
473
86
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>