1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3
<title>BitMagic: sample1.cpp Source File</title>
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
<link href="tabs.css" rel="stylesheet" type="text/css">
7
<!-- Generated by Doxygen 1.5.5 -->
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5
<title>BitMagic: Set algorithms</title>
6
<link href="tabs.css" rel="stylesheet" type="text/css"/>
7
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
10
<!-- Generated by Doxygen 1.6.1 -->
8
11
<div class="navigation" id="top">
11
14
<li><a href="index.html"><span>Main Page</span></a></li>
12
15
<li><a href="modules.html"><span>Modules</span></a></li>
13
16
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
14
<li><a href="classes.html"><span>Data Structures</span></a></li>
15
<li class="current"><a href="files.html"><span>Files</span></a></li>
17
<li><a href="annotated.html"><span>Data Structures</span></a></li>
18
<li><a href="files.html"><span>Files</span></a></li>
16
19
<li><a href="examples.html"><span>Examples</span></a></li>
19
<h1>sample1.cpp</h1><a href="a00097.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
20
<a name="l00002"></a>00002 <span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
21
<a name="l00003"></a>00003 <span class="comment"></span>
22
<a name="l00004"></a>00004 <span class="comment">Permission is hereby granted, free of charge, to any person </span>
23
<a name="l00005"></a>00005 <span class="comment">obtaining a copy of this software and associated documentation </span>
24
<a name="l00006"></a>00006 <span class="comment">files (the "Software"), to deal in the Software without restriction, </span>
25
<a name="l00007"></a>00007 <span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
26
<a name="l00008"></a>00008 <span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
27
<a name="l00009"></a>00009 <span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
28
<a name="l00010"></a>00010 <span class="comment">subject to the following conditions:</span>
29
<a name="l00011"></a>00011 <span class="comment"></span>
30
<a name="l00012"></a>00012 <span class="comment">The above copyright notice and this permission notice shall be included </span>
31
<a name="l00013"></a>00013 <span class="comment">in all copies or substantial portions of the Software.</span>
32
<a name="l00014"></a>00014 <span class="comment"></span>
33
<a name="l00015"></a>00015 <span class="comment">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, </span>
34
<a name="l00016"></a>00016 <span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
35
<a name="l00017"></a>00017 <span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
36
<a name="l00018"></a>00018 <span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
37
<a name="l00019"></a>00019 <span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
38
<a name="l00020"></a>00020 <span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
39
<a name="l00021"></a>00021 <span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
40
<a name="l00022"></a>00022 <span class="comment">*/</span>
41
<a name="l00023"></a>00023 <span class="comment"></span>
42
<a name="l00024"></a>00024 <span class="comment">/** \example sample1.cpp</span>
43
<a name="l00025"></a>00025 <span class="comment"> Example of how to use bvector template class to set</span>
44
<a name="l00026"></a>00026 <span class="comment"> bits and then retrieve indexes of ON bits.</span>
45
<a name="l00027"></a>00027 <span class="comment"> </span>
46
<a name="l00028"></a>00028 <span class="comment"> For more information please visit: http://bmagic.sourceforge.net</span>
47
<a name="l00029"></a>00029 <span class="comment"></span>
48
<a name="l00030"></a>00030 <span class="comment"> \sa bm::bvector<>::get_next() </span>
49
<a name="l00031"></a>00031 <span class="comment"> \sa bm::bvector<>::get_first() </span>
50
<a name="l00032"></a>00032 <span class="comment"> \sa bm::bvector<>::set()</span>
51
<a name="l00033"></a>00033 <span class="comment"> \sa bm::bvector<>::count() </span>
52
<a name="l00034"></a>00034 <span class="comment"> \sa bm::bvector<>::clear()</span>
53
<a name="l00035"></a>00035 <span class="comment"> </span>
54
<a name="l00036"></a>00036 <span class="comment"> */</span>
55
<a name="l00037"></a>00037
56
<a name="l00038"></a>00038
57
<a name="l00039"></a>00039 <span class="preprocessor">#include <iostream></span>
58
<a name="l00040"></a>00040 <span class="preprocessor">#include "<a class="code" href="a00082.html">bm.h</a>"</span>
59
<a name="l00041"></a>00041
60
<a name="l00042"></a>00042 <span class="keyword">using namespace </span>std;
61
<a name="l00043"></a>00043
62
<a name="l00044"></a><a class="code" href="a00097.html#840291bc02cba5474a4cb46a9b9566fe">00044</a> <span class="keywordtype">int</span> <a class="code" href="a00097.html#840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
63
<a name="l00045"></a>00045 {
64
<a name="l00046"></a>00046 <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bm::bvector<></a> bv; <span class="comment">// Bitvector variable declaration.</span>
65
<a name="l00047"></a>00047
66
<a name="l00048"></a>00048 cout << bv.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() << endl;
67
<a name="l00049"></a>00049
68
<a name="l00050"></a>00050 <span class="comment">// Set some bits.</span>
69
<a name="l00051"></a>00051
70
<a name="l00052"></a>00052 bv.<a class="code" href="a00040.html#bc85ec9da74de03ff7e2a6c836656dd8" title="Sets bit n if val is true, clears bit n if val is false.">set</a>(10);
71
<a name="l00053"></a>00053 bv.<a class="code" href="a00040.html#bc85ec9da74de03ff7e2a6c836656dd8" title="Sets bit n if val is true, clears bit n if val is false.">set</a>(100);
72
<a name="l00054"></a>00054 bv.<a class="code" href="a00040.html#bc85ec9da74de03ff7e2a6c836656dd8" title="Sets bit n if val is true, clears bit n if val is false.">set</a>(1000000);
73
<a name="l00055"></a>00055
74
<a name="l00056"></a>00056 <span class="comment">// New bitvector's count.</span>
75
<a name="l00057"></a>00057
76
<a name="l00058"></a>00058 cout << bv.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() << endl;
77
<a name="l00059"></a>00059
78
<a name="l00060"></a>00060
79
<a name="l00061"></a>00061 <span class="comment">// Print the bitvector.</span>
80
<a name="l00062"></a>00062
81
<a name="l00063"></a>00063 <span class="keywordtype">unsigned</span> value = bv.<a class="code" href="a00040.html#f3129b35cabf0554d85711c085a8616d" title="Gets number of first bit which is ON.">get_first</a>();
82
<a name="l00064"></a>00064 <span class="keywordflow">do</span>
83
<a name="l00065"></a>00065 {
84
<a name="l00066"></a>00066 cout << value;
85
<a name="l00067"></a>00067 value = bv.<a class="code" href="a00040.html#def9c095a682a9857068c280e37c8240" title="Finds the number of the next bit ON.">get_next</a>(value);
86
<a name="l00068"></a>00068 <span class="keywordflow">if</span> (value)
87
<a name="l00069"></a>00069 {
88
<a name="l00070"></a>00070 cout << <span class="stringliteral">","</span>;
89
<a name="l00071"></a>00071 }
90
<a name="l00072"></a>00072 <span class="keywordflow">else</span>
91
<a name="l00073"></a>00073 {
92
<a name="l00074"></a>00074 <span class="keywordflow">break</span>;
93
<a name="l00075"></a>00075 }
94
<a name="l00076"></a>00076 } <span class="keywordflow">while</span>(1);
95
<a name="l00077"></a>00077
96
<a name="l00078"></a>00078 cout << endl;
97
<a name="l00079"></a>00079
98
<a name="l00080"></a>00080 bv.<a class="code" href="a00040.html#fe98c658c4ee54155e61f9bdfa7b9019" title="Clears every bit in the bitvector.">clear</a>(); <span class="comment">// Clean up.</span>
99
<a name="l00081"></a>00081
100
<a name="l00082"></a>00082 cout << bv.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() << endl;
101
<a name="l00083"></a>00083
102
<a name="l00084"></a>00084 <span class="comment">// We also can use operators to set-clear bits;</span>
103
<a name="l00085"></a>00085
104
<a name="l00086"></a>00086 bv[10] = <span class="keyword">true</span>;
105
<a name="l00087"></a>00087 bv[100] = <span class="keyword">true</span>;
106
<a name="l00088"></a>00088 bv[10000] = <span class="keyword">true</span>;
107
<a name="l00089"></a>00089
108
<a name="l00090"></a>00090 cout << bv.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() << endl;
109
<a name="l00091"></a>00091
110
<a name="l00092"></a>00092 <span class="keywordflow">if</span> (bv[10])
111
<a name="l00093"></a>00093 {
112
<a name="l00094"></a>00094 bv[10] = <span class="keyword">false</span>;
113
<a name="l00095"></a>00095 }
114
<a name="l00096"></a>00096
115
<a name="l00097"></a>00097 cout << bv.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() << endl;
116
<a name="l00098"></a>00098
117
<a name="l00099"></a>00099 <span class="keywordflow">return</span> 0;
118
<a name="l00100"></a>00100 }
119
<a name="l00101"></a>00101
121
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Oct 12 12:16:39 2009 for BitMagic by
23
<div class="contents">
24
<h1>Set algorithms<br/>
26
[<a class="el" href="a00112.html">BitMagic C++ Library</a>]</small>
28
<p><div class="dynheader">
29
Collaboration diagram for Set algorithms:</div>
30
<div class="dynsection">
31
<center><table><tr><td><img src="a00119.png" border="0" alt="" usemap="#a00119_map"/>
32
<map name="a00119_map" id="a00119">
33
<area shape="rect" href="a00112.html" title="For more information please visit: http://bmagic.sourceforge.net." alt="" coords="5,5,149,35"/><area shape="rect" href="a00120.html" title="Distance metrics" alt="" coords="352,5,472,35"/></map></td></tr></table></center>
36
<table border="0" cellpadding="0" cellspacing="0">
37
<tr><td colspan="2"><h2>Modules</h2></td></tr>
38
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00120.html">Distance metrics</a></td></tr>
39
<tr><td colspan="2"><h2>Functions</h2></td></tr>
40
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
41
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#ga54ff78528c99ae3ca443eb99ba44785b">bm::combine_or</a> (BV &bv, It first, It last)</td></tr>
42
<tr><td class="mdescLeft"> </td><td class="mdescRight">OR Combine bitvector and the iterable sequence. <a href="#ga54ff78528c99ae3ca443eb99ba44785b"></a><br/></td></tr>
43
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
44
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#ga3cb362aee03de6a321495100ae5c8375">bm::combine_xor</a> (BV &bv, It first, It last)</td></tr>
45
<tr><td class="mdescLeft"> </td><td class="mdescRight">XOR Combine bitvector and the iterable sequence. <a href="#ga3cb362aee03de6a321495100ae5c8375"></a><br/></td></tr>
46
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
47
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#gab88c5bf51484323e0139aa789d7f0b98">bm::combine_sub</a> (BV &bv, It first, It last)</td></tr>
48
<tr><td class="mdescLeft"> </td><td class="mdescRight">SUB Combine bitvector and the iterable sequence. <a href="#gab88c5bf51484323e0139aa789d7f0b98"></a><br/></td></tr>
49
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
50
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#ga22922f71bd1eec8a5b663dc77b90cf6c">bm::combine_and_sorted</a> (BV &bv, It first, It last)</td></tr>
51
<tr><td class="mdescLeft"> </td><td class="mdescRight">AND Combine bitvector and the iterable sequence. <a href="#ga22922f71bd1eec8a5b663dc77b90cf6c"></a><br/></td></tr>
52
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
53
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#ga819bdab57a624a08456ea79161b9c5d2">bm::combine_and</a> (BV &bv, It first, It last)</td></tr>
54
<tr><td class="mdescLeft"> </td><td class="mdescRight">AND Combine bitvector and the iterable sequence. <a href="#ga819bdab57a624a08456ea79161b9c5d2"></a><br/></td></tr>
55
<tr><td class="memTemplParams" colspan="2">template<class BV > </td></tr>
56
<tr><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="a00110.html#aa3824d882a037396370b16f2f0a8bf37">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#gac7a59d3bc266310ec127cb3efadb0d33">bm::count_intervals</a> (const BV &bv)</td></tr>
57
<tr><td class="mdescLeft"> </td><td class="mdescRight">Compute number of bit intervals (GAPs) in the bitvector. <a href="#gac7a59d3bc266310ec127cb3efadb0d33"></a><br/></td></tr>
58
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
59
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00119.html#gacd88ed9539553dd93419b7029e8a4584">bm::export_array</a> (BV &bv, It first, It last)</td></tr>
60
<tr><td class="mdescLeft"> </td><td class="mdescRight">Export bitset from an array of binary data representing the bit vector. <a href="#gacd88ed9539553dd93419b7029e8a4584"></a><br/></td></tr>
62
<hr/><a name="_details"></a><h2>Detailed Description</h2>
63
<p>Set algorithms </p>
64
<hr/><h2>Function Documentation</h2>
65
<a class="anchor" id="ga819bdab57a624a08456ea79161b9c5d2"></a><!-- doxytag: member="bm::combine_and" ref="ga819bdab57a624a08456ea79161b9c5d2" args="(BV &bv, It first, It last)" -->
67
<div class="memproto">
68
<div class="memtemplate">
69
template<class BV , class It > </div>
70
<table class="memname">
72
<td class="memname">void bm::combine_and </td>
74
<td class="paramtype">BV & </td>
75
<td class="paramname"> <em>bv</em>, </td>
78
<td class="paramkey"></td>
80
<td class="paramtype">It </td>
81
<td class="paramname"> <em>first</em>, </td>
84
<td class="paramkey"></td>
86
<td class="paramtype">It </td>
87
<td class="paramname"> <em>last</em></td><td> </td>
92
<td></td><td></td><td><code> [inline]</code></td>
98
<p>AND Combine bitvector and the iterable sequence. </p>
99
<p>Algorithm combines <a class="el" href="a00043.html" title="bitvector with runtime compression of bits.">bvector</a> with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.</p>
100
<dl><dt><b>Parameters:</b></dt><dd>
101
<table border="0" cellspacing="2" cellpadding="0">
102
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
103
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
104
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence</td></tr>
108
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00119.html#ga22922f71bd1eec8a5b663dc77b90cf6c" title="AND Combine bitvector and the iterable sequence.">combine_and_sorted</a> </dd></dl>
110
<p>Definition at line <a class="el" href="a00086_source.html#l01382">1382</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
112
<p>References <a class="el" href="a00086_source.html#l01105">bm::combine_or()</a>.</p>
116
<a class="anchor" id="ga22922f71bd1eec8a5b663dc77b90cf6c"></a><!-- doxytag: member="bm::combine_and_sorted" ref="ga22922f71bd1eec8a5b663dc77b90cf6c" args="(BV &bv, It first, It last)" -->
117
<div class="memitem">
118
<div class="memproto">
119
<div class="memtemplate">
120
template<class BV , class It > </div>
121
<table class="memname">
123
<td class="memname">void bm::combine_and_sorted </td>
125
<td class="paramtype">BV & </td>
126
<td class="paramname"> <em>bv</em>, </td>
129
<td class="paramkey"></td>
131
<td class="paramtype">It </td>
132
<td class="paramname"> <em>first</em>, </td>
135
<td class="paramkey"></td>
137
<td class="paramtype">It </td>
138
<td class="paramname"> <em>last</em></td><td> </td>
143
<td></td><td></td><td><code> [inline]</code></td>
149
<p>AND Combine bitvector and the iterable sequence. </p>
150
<p>Algorithm combines <a class="el" href="a00043.html" title="bitvector with runtime compression of bits.">bvector</a> with sorted sequence of integers (represents another set).</p>
151
<dl><dt><b>Parameters:</b></dt><dd>
152
<table border="0" cellspacing="2" cellpadding="0">
153
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
154
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
155
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
160
<p>Definition at line <a class="el" href="a00086_source.html#l01350">1350</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
162
<p>References <a class="el" href="a00089_source.html#l00047">BM_ASSERT</a>.</p>
166
<a class="anchor" id="ga54ff78528c99ae3ca443eb99ba44785b"></a><!-- doxytag: member="bm::combine_or" ref="ga54ff78528c99ae3ca443eb99ba44785b" args="(BV &bv, It first, It last)" -->
167
<div class="memitem">
168
<div class="memproto">
169
<div class="memtemplate">
170
template<class BV , class It > </div>
171
<table class="memname">
173
<td class="memname">void bm::combine_or </td>
175
<td class="paramtype">BV & </td>
176
<td class="paramname"> <em>bv</em>, </td>
179
<td class="paramkey"></td>
181
<td class="paramtype">It </td>
182
<td class="paramname"> <em>first</em>, </td>
185
<td class="paramkey"></td>
187
<td class="paramtype">It </td>
188
<td class="paramname"> <em>last</em></td><td> </td>
193
<td></td><td></td><td><code> [inline]</code></td>
199
<p>OR Combine bitvector and the iterable sequence. </p>
200
<p>Algorithm combines <a class="el" href="a00043.html" title="bitvector with runtime compression of bits.">bvector</a> with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.</p>
201
<dl><dt><b>Parameters:</b></dt><dd>
202
<table border="0" cellspacing="2" cellpadding="0">
203
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
204
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
205
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
210
<p>Definition at line <a class="el" href="a00086_source.html#l01105">1105</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
212
<p>References <a class="el" href="a00086_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00089_source.html#l00047">BM_ASSERT</a>, <a class="el" href="a00089_source.html#l00092">BMGAP_PTR</a>, <a class="el" href="a00090_source.html#l02151">bm::gap_limit()</a>, <a class="el" href="a00090_source.html#l01098">bm::gap_set_value()</a>, <a class="el" href="a00088_source.html#l00048">bm::id_max</a>, <a class="el" href="a00088_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00088_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00088_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00088_source.html#l00062">bm::set_word_shift</a>.</p>
214
<p>Referenced by <a class="el" href="a00086_source.html#l01382">bm::combine_and()</a>.</p>
218
<a class="anchor" id="gab88c5bf51484323e0139aa789d7f0b98"></a><!-- doxytag: member="bm::combine_sub" ref="gab88c5bf51484323e0139aa789d7f0b98" args="(BV &bv, It first, It last)" -->
219
<div class="memitem">
220
<div class="memproto">
221
<div class="memtemplate">
222
template<class BV , class It > </div>
223
<table class="memname">
225
<td class="memname">void bm::combine_sub </td>
227
<td class="paramtype">BV & </td>
228
<td class="paramname"> <em>bv</em>, </td>
231
<td class="paramkey"></td>
233
<td class="paramtype">It </td>
234
<td class="paramname"> <em>first</em>, </td>
237
<td class="paramkey"></td>
239
<td class="paramtype">It </td>
240
<td class="paramname"> <em>last</em></td><td> </td>
245
<td></td><td></td><td><code> [inline]</code></td>
251
<p>SUB Combine bitvector and the iterable sequence. </p>
252
<p>Algorithm combines <a class="el" href="a00043.html" title="bitvector with runtime compression of bits.">bvector</a> with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.</p>
253
<dl><dt><b>Parameters:</b></dt><dd>
254
<table border="0" cellspacing="2" cellpadding="0">
255
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
256
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
257
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
262
<p>Definition at line <a class="el" href="a00086_source.html#l01268">1268</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
264
<p>References <a class="el" href="a00086_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00089_source.html#l00047">BM_ASSERT</a>, <a class="el" href="a00089_source.html#l00092">BMGAP_PTR</a>, <a class="el" href="a00090_source.html#l02151">bm::gap_limit()</a>, <a class="el" href="a00090_source.html#l01098">bm::gap_set_value()</a>, <a class="el" href="a00090_source.html#l00454">bm::gap_test()</a>, <a class="el" href="a00088_source.html#l00048">bm::id_max</a>, <a class="el" href="a00088_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00088_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00088_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00088_source.html#l00062">bm::set_word_shift</a>.</p>
268
<a class="anchor" id="ga3cb362aee03de6a321495100ae5c8375"></a><!-- doxytag: member="bm::combine_xor" ref="ga3cb362aee03de6a321495100ae5c8375" args="(BV &bv, It first, It last)" -->
269
<div class="memitem">
270
<div class="memproto">
271
<div class="memtemplate">
272
template<class BV , class It > </div>
273
<table class="memname">
275
<td class="memname">void bm::combine_xor </td>
277
<td class="paramtype">BV & </td>
278
<td class="paramname"> <em>bv</em>, </td>
281
<td class="paramkey"></td>
283
<td class="paramtype">It </td>
284
<td class="paramname"> <em>first</em>, </td>
287
<td class="paramkey"></td>
289
<td class="paramtype">It </td>
290
<td class="paramname"> <em>last</em></td><td> </td>
295
<td></td><td></td><td><code> [inline]</code></td>
301
<p>XOR Combine bitvector and the iterable sequence. </p>
302
<p>Algorithm combines <a class="el" href="a00043.html" title="bitvector with runtime compression of bits.">bvector</a> with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.</p>
303
<dl><dt><b>Parameters:</b></dt><dd>
304
<table border="0" cellspacing="2" cellpadding="0">
305
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
306
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
307
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
312
<p>Definition at line <a class="el" href="a00086_source.html#l01184">1184</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
314
<p>References <a class="el" href="a00086_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00089_source.html#l00047">BM_ASSERT</a>, <a class="el" href="a00089_source.html#l00092">BMGAP_PTR</a>, <a class="el" href="a00090_source.html#l02151">bm::gap_limit()</a>, <a class="el" href="a00090_source.html#l01098">bm::gap_set_value()</a>, <a class="el" href="a00090_source.html#l00454">bm::gap_test()</a>, <a class="el" href="a00088_source.html#l00048">bm::id_max</a>, <a class="el" href="a00088_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00088_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00088_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00088_source.html#l00062">bm::set_word_shift</a>.</p>
318
<a class="anchor" id="gac7a59d3bc266310ec127cb3efadb0d33"></a><!-- doxytag: member="bm::count_intervals" ref="gac7a59d3bc266310ec127cb3efadb0d33" args="(const BV &bv)" -->
319
<div class="memitem">
320
<div class="memproto">
321
<div class="memtemplate">
322
template<class BV > </div>
323
<table class="memname">
325
<td class="memname"><a class="el" href="a00110.html#aa3824d882a037396370b16f2f0a8bf37">bm::id_t</a> bm::count_intervals </td>
327
<td class="paramtype">const BV & </td>
328
<td class="paramname"> <em>bv</em></td>
329
<td> ) </td>
330
<td><code> [inline]</code></td>
336
<p>Compute number of bit intervals (GAPs) in the bitvector. </p>
337
<p>Algorithm traverses bit vector and count number of uninterrupted intervals of 1s and 0s. </p>
340
00001111100000 - gives us 3 intervals
341
10001111100000 - 4 intervals
342
00000000000000 - 1 interval
343
11111111111111 - 1 interval
344
</pre> <dl class="return"><dt><b>Returns:</b></dt><dd>Number of intervals </dd></dl>
346
<p>Definition at line <a class="el" href="a00086_source.html#l01405">1405</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
348
<p>References <a class="el" href="a00090_source.html#l00557">bm::for_each_block()</a>, and <a class="el" href="a00088_source.html#l00080">bm::set_array_size</a>.</p>
352
<a class="anchor" id="gacd88ed9539553dd93419b7029e8a4584"></a><!-- doxytag: member="bm::export_array" ref="gacd88ed9539553dd93419b7029e8a4584" args="(BV &bv, It first, It last)" -->
353
<div class="memitem">
354
<div class="memproto">
355
<div class="memtemplate">
356
template<class BV , class It > </div>
357
<table class="memname">
359
<td class="memname">void bm::export_array </td>
361
<td class="paramtype">BV & </td>
362
<td class="paramname"> <em>bv</em>, </td>
365
<td class="paramkey"></td>
367
<td class="paramtype">It </td>
368
<td class="paramname"> <em>first</em>, </td>
371
<td class="paramkey"></td>
373
<td class="paramtype">It </td>
374
<td class="paramname"> <em>last</em></td><td> </td>
379
<td></td><td></td><td><code> [inline]</code></td>
385
<p>Export bitset from an array of binary data representing the bit vector. </p>
386
<p>Input array can be array of ints, chars or other native C types. Method works with iterators, which makes it compatible with STL containers and C arrays</p>
387
<dl><dt><b>Parameters:</b></dt><dd>
388
<table border="0" cellspacing="2" cellpadding="0">
389
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
390
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
391
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
396
<p>Definition at line <a class="el" href="a00086_source.html#l01431">1431</a> of file <a class="el" href="a00086_source.html">bmalgo_impl.h</a>.</p>
398
<p>References <a class="el" href="a00089_source.html#l00047">BM_ASSERT</a>, <a class="el" href="a00088_source.html#l00116">bm::BM_BIT</a>, <a class="el" href="a00089_source.html#l00092">BMGAP_PTR</a>, <a class="el" href="a00088_source.html#l00052">bm::set_block_size</a>, and <a class="el" href="a00088_source.html#l00083">bm::set_total_blocks</a>.</p>
403
<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Nov 22 10:49:42 2009 for BitMagic by
122
404
<a href="http://www.doxygen.org/index.html">
123
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
405
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>