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: sample6.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>sample6.cpp</h1><a href="a00102.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 sample6.cpp</span>
43
<a name="l00025"></a>00025 <span class="comment"> This example demonstrates using of custom memory allocators.</span>
44
<a name="l00026"></a>00026 <span class="comment"> In this case allocator works as a memory checker, counts number of </span>
45
<a name="l00027"></a>00027 <span class="comment"> allocations and deallocations to make sure that there is no memory leaks. </span>
46
<a name="l00028"></a>00028 <span class="comment"></span>
47
<a name="l00029"></a>00029 <span class="comment">For more information please visit: http://bmagic.sourceforge.net</span>
48
<a name="l00030"></a>00030 <span class="comment">*/</span>
49
<a name="l00031"></a>00031
50
<a name="l00032"></a>00032 <span class="preprocessor">#include <iostream></span>
51
<a name="l00033"></a>00033 <span class="preprocessor">#include <assert.h></span>
52
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="a00082.html">bm.h</a>"</span>
53
<a name="l00035"></a>00035
54
<a name="l00036"></a>00036 <span class="keyword">using namespace </span>std;
55
<a name="l00037"></a>00037
56
<a name="l00038"></a>00038
57
<a name="l00039"></a>00039 <span class="comment">// Custom allocator keeps number of all alloc/free calls.</span>
58
<a name="l00040"></a>00040 <span class="comment">// It also reservs the front word of the allocated block and saves</span>
59
<a name="l00041"></a>00041 <span class="comment">// number of elements allocated. On deallocation it makes sure</span>
60
<a name="l00042"></a>00042 <span class="comment">// it deallocates the same size as allocated</span>
61
<a name="l00043"></a>00043
62
<a name="l00044"></a><a class="code" href="a00055.html">00044</a> <span class="keyword">class </span><a class="code" href="a00055.html">dbg_block_allocator</a>
63
<a name="l00045"></a>00045 {
64
<a name="l00046"></a>00046 <span class="keyword">public</span>:
65
<a name="l00047"></a><a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">00047</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">na_</a>;
66
<a name="l00048"></a><a class="code" href="a00055.html#adb605865e1f0ea195000e51e90001e6">00048</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00055.html#adb605865e1f0ea195000e51e90001e6">nf_</a>;
67
<a name="l00049"></a>00049
68
<a name="l00050"></a><a class="code" href="a00055.html#93d82be8946cf5b72c9d7c6cb956e804">00050</a> <span class="keyword">static</span> <a class="code" href="a00106.html#17fd5ba52db3ddda05e6f8dd5000a1a4">bm::word_t</a>* <a class="code" href="a00055.html#93d82be8946cf5b72c9d7c6cb956e804">allocate</a>(<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">void</span> *)
69
<a name="l00051"></a>00051 {
70
<a name="l00052"></a>00052 ++<a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">na_</a>;
71
<a name="l00053"></a>00053 assert(n);
72
<a name="l00054"></a>00054 <a class="code" href="a00106.html#17fd5ba52db3ddda05e6f8dd5000a1a4">bm::word_t</a>* p =
73
<a name="l00055"></a>00055 (<a class="code" href="a00106.html#17fd5ba52db3ddda05e6f8dd5000a1a4">bm::word_t</a>*) ::malloc((n+1) * <span class="keyword">sizeof</span>(<a class="code" href="a00106.html#17fd5ba52db3ddda05e6f8dd5000a1a4">bm::word_t</a>));
74
<a name="l00056"></a>00056 *p = n;
75
<a name="l00057"></a>00057 <span class="keywordflow">return</span> ++p;
76
<a name="l00058"></a>00058 }
77
<a name="l00059"></a>00059
78
<a name="l00060"></a><a class="code" href="a00055.html#56d40f419ba5f9e54b61d8ab88f93866">00060</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00055.html#56d40f419ba5f9e54b61d8ab88f93866">deallocate</a>(<a class="code" href="a00106.html#17fd5ba52db3ddda05e6f8dd5000a1a4">bm::word_t</a>* p, <span class="keywordtype">size_t</span> n)
79
<a name="l00061"></a>00061 {
80
<a name="l00062"></a>00062 ++<a class="code" href="a00055.html#adb605865e1f0ea195000e51e90001e6">nf_</a>;
81
<a name="l00063"></a>00063 --p;
82
<a name="l00064"></a>00064 assert(*p == n);
83
<a name="l00065"></a>00065 ::free(p);
84
<a name="l00066"></a>00066 }
85
<a name="l00067"></a>00067
86
<a name="l00068"></a><a class="code" href="a00055.html#316046faa0e5010b9d4b4881977dde49">00068</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00055.html#316046faa0e5010b9d4b4881977dde49">balance</a>()
87
<a name="l00069"></a>00069 {
88
<a name="l00070"></a>00070 <span class="keywordflow">return</span> <a class="code" href="a00055.html#adb605865e1f0ea195000e51e90001e6">nf_</a> - <a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">na_</a>;
89
<a name="l00071"></a>00071 }
90
<a name="l00072"></a>00072 };
91
<a name="l00073"></a>00073
92
<a name="l00074"></a>00074 <span class="keywordtype">unsigned</span> <a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">dbg_block_allocator::na_</a> = 0;
93
<a name="l00075"></a>00075 <span class="keywordtype">unsigned</span> <a class="code" href="a00055.html#adb605865e1f0ea195000e51e90001e6">dbg_block_allocator::nf_</a> = 0;
94
<a name="l00076"></a>00076
95
<a name="l00077"></a><a class="code" href="a00056.html">00077</a> <span class="keyword">class </span><a class="code" href="a00056.html">dbg_ptr_allocator</a>
96
<a name="l00078"></a>00078 {
97
<a name="l00079"></a>00079 <span class="keyword">public</span>:
98
<a name="l00080"></a><a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">00080</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">na_</a>;
99
<a name="l00081"></a><a class="code" href="a00056.html#fbbe7e12818ba2c51358b66d00fc05f0">00081</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00056.html#fbbe7e12818ba2c51358b66d00fc05f0">nf_</a>;
100
<a name="l00082"></a>00082
101
<a name="l00083"></a><a class="code" href="a00056.html#15a6c29419ebabc9221051cdd63e9495">00083</a> <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="a00056.html#15a6c29419ebabc9221051cdd63e9495">allocate</a>(<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">void</span> *)
102
<a name="l00084"></a>00084 {
103
<a name="l00085"></a>00085 ++<a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">na_</a>;
104
<a name="l00086"></a>00086 assert(<span class="keyword">sizeof</span>(<span class="keywordtype">size_t</span>) == <span class="keyword">sizeof</span>(<span class="keywordtype">void</span>*));
105
<a name="l00087"></a>00087 <span class="keywordtype">void</span>* p = ::malloc((n+1) * <span class="keyword">sizeof</span>(<span class="keywordtype">void</span>*));
106
<a name="l00088"></a>00088 <span class="keywordtype">size_t</span>* s = (<span class="keywordtype">size_t</span>*) p;
107
<a name="l00089"></a>00089 *s = n;
108
<a name="l00090"></a>00090 <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)++s;
109
<a name="l00091"></a>00091 }
110
<a name="l00092"></a>00092
111
<a name="l00093"></a><a class="code" href="a00056.html#89cd3e8e84ef4a4598446ba8fa8c10a3">00093</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00056.html#89cd3e8e84ef4a4598446ba8fa8c10a3">deallocate</a>(<span class="keywordtype">void</span>* p, <span class="keywordtype">size_t</span> n)
112
<a name="l00094"></a>00094 {
113
<a name="l00095"></a>00095 ++<a class="code" href="a00056.html#fbbe7e12818ba2c51358b66d00fc05f0">nf_</a>;
114
<a name="l00096"></a>00096 <span class="keywordtype">size_t</span>* s = (<span class="keywordtype">size_t</span>*) p;
115
<a name="l00097"></a>00097 --s;
116
<a name="l00098"></a>00098 assert(*s == n);
117
<a name="l00099"></a>00099 ::free(s);
118
<a name="l00100"></a>00100 }
119
<a name="l00101"></a>00101
120
<a name="l00102"></a><a class="code" href="a00056.html#521bc1068c669de23dc20d582d229918">00102</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00056.html#521bc1068c669de23dc20d582d229918">balance</a>()
121
<a name="l00103"></a>00103 {
122
<a name="l00104"></a>00104 <span class="keywordflow">return</span> <a class="code" href="a00056.html#fbbe7e12818ba2c51358b66d00fc05f0">nf_</a> - <a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">na_</a>;
123
<a name="l00105"></a>00105 }
124
<a name="l00106"></a>00106
125
<a name="l00107"></a>00107 };
126
<a name="l00108"></a>00108
127
<a name="l00109"></a>00109 <span class="keywordtype">unsigned</span> <a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">dbg_ptr_allocator::na_</a> = 0;
128
<a name="l00110"></a>00110 <span class="keywordtype">unsigned</span> <a class="code" href="a00056.html#fbbe7e12818ba2c51358b66d00fc05f0">dbg_ptr_allocator::nf_</a> = 0;
129
<a name="l00111"></a>00111
130
<a name="l00112"></a>00112
131
<a name="l00113"></a><a class="code" href="a00102.html#a932e8e72ba07938f1a001b6cfcb614e">00113</a> <span class="keyword">typedef</span> <a class="code" href="a00073.html" title="BM style allocator adapter.">bm::mem_alloc<dbg_block_allocator, dbg_ptr_allocator></a> <a class="code" href="a00073.html" title="BM style allocator adapter.">dbg_alloc</a>;
132
<a name="l00114"></a>00114
133
<a name="l00115"></a><a class="code" href="a00102.html#c07bb102df543a0c581493c5f35b2129">00115</a> <span class="keyword">typedef</span> <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bm::bvector<dbg_alloc></a> <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bvect</a>;
134
<a name="l00116"></a>00116
135
<a name="l00117"></a>00117
136
<a name="l00118"></a>00118
137
<a name="l00119"></a><a class="code" href="a00102.html#840291bc02cba5474a4cb46a9b9566fe">00119</a> <span class="keywordtype">int</span> <a class="code" href="a00097.html#840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
138
<a name="l00120"></a>00120 {
139
<a name="l00121"></a>00121 {
140
<a name="l00122"></a>00122 <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bvect</a> bv;
141
<a name="l00123"></a>00123
142
<a name="l00124"></a>00124 bv[10] = <span class="keyword">true</span>;
143
<a name="l00125"></a>00125 bv[100000] = <span class="keyword">true</span>;
144
<a name="l00126"></a>00126 bv[10000000] = <span class="keyword">false</span>;
145
<a name="l00127"></a>00127 }
146
<a name="l00128"></a>00128
147
<a name="l00129"></a>00129 cout << <span class="stringliteral">"Number of BLOCK allocations = "</span> << <a class="code" href="a00055.html#2e3f8148fefdb34093ebf3db55b6175b">dbg_block_allocator::na_</a> << endl;
148
<a name="l00130"></a>00130 cout << <span class="stringliteral">"Number of PTR allocations = "</span> << <a class="code" href="a00056.html#1839c318b76fefce64ba0a0aba52e2b0">dbg_ptr_allocator::na_</a> << endl;
149
<a name="l00131"></a>00131
150
<a name="l00132"></a>00132 assert(<a class="code" href="a00055.html#316046faa0e5010b9d4b4881977dde49">dbg_block_allocator::balance</a>() == 0);
151
<a name="l00133"></a>00133 assert(<a class="code" href="a00056.html#521bc1068c669de23dc20d582d229918">dbg_ptr_allocator::balance</a>() == 0);
152
<a name="l00134"></a>00134
153
<a name="l00135"></a>00135 <span class="keywordflow">return</span> 0;
154
<a name="l00136"></a>00136 }
155
<a name="l00137"></a>00137
156
<a name="l00138"></a>00138
158
<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="a00117.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="a00124.png" border="0" alt="" usemap="#a00124_map"/>
32
<map name="a00124_map" id="a00124">
33
<area shape="rect" href="a00117.html" title="For more information please visit: http://bmagic.sourceforge.net." alt="" coords="5,5,149,35"/><area shape="rect" href="a00125.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>Data Structures</h2></td></tr>
38
<tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="a00079.html">bm::random_subset< BV ></a></td></tr>
39
<tr><td colspan="2"><h2>Modules</h2></td></tr>
40
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00125.html">Distance metrics</a></td></tr>
41
<tr><td colspan="2"><h2>Functions</h2></td></tr>
42
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
43
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#ga54ff78528c99ae3ca443eb99ba44785b">bm::combine_or</a> (BV &bv, It first, It last)</td></tr>
44
<tr><td class="mdescLeft"> </td><td class="mdescRight">OR Combine bitvector and the iterable sequence. <a href="#ga54ff78528c99ae3ca443eb99ba44785b"></a><br/></td></tr>
45
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
46
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#ga3cb362aee03de6a321495100ae5c8375">bm::combine_xor</a> (BV &bv, It first, It last)</td></tr>
47
<tr><td class="mdescLeft"> </td><td class="mdescRight">XOR Combine bitvector and the iterable sequence. <a href="#ga3cb362aee03de6a321495100ae5c8375"></a><br/></td></tr>
48
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
49
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#gab88c5bf51484323e0139aa789d7f0b98">bm::combine_sub</a> (BV &bv, It first, It last)</td></tr>
50
<tr><td class="mdescLeft"> </td><td class="mdescRight">SUB Combine bitvector and the iterable sequence. <a href="#gab88c5bf51484323e0139aa789d7f0b98"></a><br/></td></tr>
51
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
52
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#ga22922f71bd1eec8a5b663dc77b90cf6c">bm::combine_and_sorted</a> (BV &bv, It first, It last)</td></tr>
53
<tr><td class="mdescLeft"> </td><td class="mdescRight">AND Combine bitvector and the iterable sequence. <a href="#ga22922f71bd1eec8a5b663dc77b90cf6c"></a><br/></td></tr>
54
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
55
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#ga819bdab57a624a08456ea79161b9c5d2">bm::combine_and</a> (BV &bv, It first, It last)</td></tr>
56
<tr><td class="mdescLeft"> </td><td class="mdescRight">AND Combine bitvector and the iterable sequence. <a href="#ga819bdab57a624a08456ea79161b9c5d2"></a><br/></td></tr>
57
<tr><td class="memTemplParams" colspan="2">template<class BV > </td></tr>
58
<tr><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="a00115.html#aa3824d882a037396370b16f2f0a8bf37">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#gac7a59d3bc266310ec127cb3efadb0d33">bm::count_intervals</a> (const BV &bv)</td></tr>
59
<tr><td class="mdescLeft"> </td><td class="mdescRight">Compute number of bit intervals (GAPs) in the bitvector. <a href="#gac7a59d3bc266310ec127cb3efadb0d33"></a><br/></td></tr>
60
<tr><td class="memTemplParams" colspan="2">template<class BV , class It > </td></tr>
61
<tr><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00124.html#gacd88ed9539553dd93419b7029e8a4584">bm::export_array</a> (BV &bv, It first, It last)</td></tr>
62
<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>
64
<hr/><a name="_details"></a><h2>Detailed Description</h2>
65
<p>Set algorithms </p>
66
<hr/><h2>Function Documentation</h2>
67
<a class="anchor" id="ga819bdab57a624a08456ea79161b9c5d2"></a><!-- doxytag: member="bm::combine_and" ref="ga819bdab57a624a08456ea79161b9c5d2" args="(BV &bv, It first, It last)" -->
69
<div class="memproto">
70
<div class="memtemplate">
71
template<class BV , class It > </div>
72
<table class="memname">
74
<td class="memname">void bm::combine_and </td>
76
<td class="paramtype">BV & </td>
77
<td class="paramname"> <em>bv</em>, </td>
80
<td class="paramkey"></td>
82
<td class="paramtype">It </td>
83
<td class="paramname"> <em>first</em>, </td>
86
<td class="paramkey"></td>
88
<td class="paramtype">It </td>
89
<td class="paramname"> <em>last</em></td><td> </td>
94
<td></td><td></td><td><code> [inline]</code></td>
100
<p>AND Combine bitvector and the iterable sequence. </p>
101
<p>Algorithm combines <a class="el" href="a00044.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>
102
<dl><dt><b>Parameters:</b></dt><dd>
103
<table border="0" cellspacing="2" cellpadding="0">
104
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
105
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
106
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence</td></tr>
110
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00124.html#ga22922f71bd1eec8a5b663dc77b90cf6c" title="AND Combine bitvector and the iterable sequence.">combine_and_sorted</a> </dd></dl>
112
<p>Definition at line <a class="el" href="a00089_source.html#l01382">1382</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
114
<p>References <a class="el" href="a00089_source.html#l01105">bm::combine_or()</a>.</p>
118
<a class="anchor" id="ga22922f71bd1eec8a5b663dc77b90cf6c"></a><!-- doxytag: member="bm::combine_and_sorted" ref="ga22922f71bd1eec8a5b663dc77b90cf6c" args="(BV &bv, It first, It last)" -->
119
<div class="memitem">
120
<div class="memproto">
121
<div class="memtemplate">
122
template<class BV , class It > </div>
123
<table class="memname">
125
<td class="memname">void bm::combine_and_sorted </td>
127
<td class="paramtype">BV & </td>
128
<td class="paramname"> <em>bv</em>, </td>
131
<td class="paramkey"></td>
133
<td class="paramtype">It </td>
134
<td class="paramname"> <em>first</em>, </td>
137
<td class="paramkey"></td>
139
<td class="paramtype">It </td>
140
<td class="paramname"> <em>last</em></td><td> </td>
145
<td></td><td></td><td><code> [inline]</code></td>
151
<p>AND Combine bitvector and the iterable sequence. </p>
152
<p>Algorithm combines <a class="el" href="a00044.html" title="bitvector with runtime compression of bits.">bvector</a> with sorted sequence of integers (represents another set).</p>
153
<dl><dt><b>Parameters:</b></dt><dd>
154
<table border="0" cellspacing="2" cellpadding="0">
155
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
156
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
157
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
162
<p>Definition at line <a class="el" href="a00089_source.html#l01350">1350</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
164
<p>References <a class="el" href="a00092_source.html#l00050">BM_ASSERT</a>.</p>
168
<a class="anchor" id="ga54ff78528c99ae3ca443eb99ba44785b"></a><!-- doxytag: member="bm::combine_or" ref="ga54ff78528c99ae3ca443eb99ba44785b" args="(BV &bv, It first, It last)" -->
169
<div class="memitem">
170
<div class="memproto">
171
<div class="memtemplate">
172
template<class BV , class It > </div>
173
<table class="memname">
175
<td class="memname">void bm::combine_or </td>
177
<td class="paramtype">BV & </td>
178
<td class="paramname"> <em>bv</em>, </td>
181
<td class="paramkey"></td>
183
<td class="paramtype">It </td>
184
<td class="paramname"> <em>first</em>, </td>
187
<td class="paramkey"></td>
189
<td class="paramtype">It </td>
190
<td class="paramname"> <em>last</em></td><td> </td>
195
<td></td><td></td><td><code> [inline]</code></td>
201
<p>OR Combine bitvector and the iterable sequence. </p>
202
<p>Algorithm combines <a class="el" href="a00044.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>
203
<dl><dt><b>Parameters:</b></dt><dd>
204
<table border="0" cellspacing="2" cellpadding="0">
205
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
206
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
207
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
212
<p>Definition at line <a class="el" href="a00089_source.html#l01105">1105</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
214
<p>References <a class="el" href="a00089_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00092_source.html#l00050">BM_ASSERT</a>, <a class="el" href="a00092_source.html#l00095">BMGAP_PTR</a>, <a class="el" href="a00093_source.html#l02186">bm::gap_limit()</a>, <a class="el" href="a00093_source.html#l01133">bm::gap_set_value()</a>, <a class="el" href="a00091_source.html#l00048">bm::id_max</a>, <a class="el" href="a00091_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00091_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00091_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00091_source.html#l00062">bm::set_word_shift</a>.</p>
216
<p>Referenced by <a class="el" href="a00089_source.html#l01382">bm::combine_and()</a>.</p>
220
<a class="anchor" id="gab88c5bf51484323e0139aa789d7f0b98"></a><!-- doxytag: member="bm::combine_sub" ref="gab88c5bf51484323e0139aa789d7f0b98" args="(BV &bv, It first, It last)" -->
221
<div class="memitem">
222
<div class="memproto">
223
<div class="memtemplate">
224
template<class BV , class It > </div>
225
<table class="memname">
227
<td class="memname">void bm::combine_sub </td>
229
<td class="paramtype">BV & </td>
230
<td class="paramname"> <em>bv</em>, </td>
233
<td class="paramkey"></td>
235
<td class="paramtype">It </td>
236
<td class="paramname"> <em>first</em>, </td>
239
<td class="paramkey"></td>
241
<td class="paramtype">It </td>
242
<td class="paramname"> <em>last</em></td><td> </td>
247
<td></td><td></td><td><code> [inline]</code></td>
253
<p>SUB Combine bitvector and the iterable sequence. </p>
254
<p>Algorithm combines <a class="el" href="a00044.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>
255
<dl><dt><b>Parameters:</b></dt><dd>
256
<table border="0" cellspacing="2" cellpadding="0">
257
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
258
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
259
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
264
<p>Definition at line <a class="el" href="a00089_source.html#l01268">1268</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
266
<p>References <a class="el" href="a00089_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00092_source.html#l00050">BM_ASSERT</a>, <a class="el" href="a00092_source.html#l00095">BMGAP_PTR</a>, <a class="el" href="a00093_source.html#l02186">bm::gap_limit()</a>, <a class="el" href="a00093_source.html#l01133">bm::gap_set_value()</a>, <a class="el" href="a00093_source.html#l00489">bm::gap_test()</a>, <a class="el" href="a00091_source.html#l00048">bm::id_max</a>, <a class="el" href="a00091_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00091_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00091_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00091_source.html#l00062">bm::set_word_shift</a>.</p>
270
<a class="anchor" id="ga3cb362aee03de6a321495100ae5c8375"></a><!-- doxytag: member="bm::combine_xor" ref="ga3cb362aee03de6a321495100ae5c8375" args="(BV &bv, It first, It last)" -->
271
<div class="memitem">
272
<div class="memproto">
273
<div class="memtemplate">
274
template<class BV , class It > </div>
275
<table class="memname">
277
<td class="memname">void bm::combine_xor </td>
279
<td class="paramtype">BV & </td>
280
<td class="paramname"> <em>bv</em>, </td>
283
<td class="paramkey"></td>
285
<td class="paramtype">It </td>
286
<td class="paramname"> <em>first</em>, </td>
289
<td class="paramkey"></td>
291
<td class="paramtype">It </td>
292
<td class="paramname"> <em>last</em></td><td> </td>
297
<td></td><td></td><td><code> [inline]</code></td>
303
<p>XOR Combine bitvector and the iterable sequence. </p>
304
<p>Algorithm combines <a class="el" href="a00044.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>
305
<dl><dt><b>Parameters:</b></dt><dd>
306
<table border="0" cellspacing="2" cellpadding="0">
307
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
308
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
309
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
314
<p>Definition at line <a class="el" href="a00089_source.html#l01184">1184</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
316
<p>References <a class="el" href="a00089_source.html#l01075">bm::block_range_scan()</a>, <a class="el" href="a00092_source.html#l00050">BM_ASSERT</a>, <a class="el" href="a00092_source.html#l00095">BMGAP_PTR</a>, <a class="el" href="a00093_source.html#l02186">bm::gap_limit()</a>, <a class="el" href="a00093_source.html#l01133">bm::gap_set_value()</a>, <a class="el" href="a00093_source.html#l00489">bm::gap_test()</a>, <a class="el" href="a00091_source.html#l00048">bm::id_max</a>, <a class="el" href="a00091_source.html#l00054">bm::set_block_mask</a>, <a class="el" href="a00091_source.html#l00053">bm::set_block_shift</a>, <a class="el" href="a00091_source.html#l00063">bm::set_word_mask</a>, and <a class="el" href="a00091_source.html#l00062">bm::set_word_shift</a>.</p>
320
<a class="anchor" id="gac7a59d3bc266310ec127cb3efadb0d33"></a><!-- doxytag: member="bm::count_intervals" ref="gac7a59d3bc266310ec127cb3efadb0d33" args="(const BV &bv)" -->
321
<div class="memitem">
322
<div class="memproto">
323
<div class="memtemplate">
324
template<class BV > </div>
325
<table class="memname">
327
<td class="memname"><a class="el" href="a00115.html#aa3824d882a037396370b16f2f0a8bf37">bm::id_t</a> bm::count_intervals </td>
329
<td class="paramtype">const BV & </td>
330
<td class="paramname"> <em>bv</em></td>
331
<td> ) </td>
332
<td><code> [inline]</code></td>
338
<p>Compute number of bit intervals (GAPs) in the bitvector. </p>
339
<p>Algorithm traverses bit vector and count number of uninterrupted intervals of 1s and 0s. </p>
342
00001111100000 - gives us 3 intervals
343
10001111100000 - 4 intervals
344
00000000000000 - 1 interval
345
11111111111111 - 1 interval
346
</pre> <dl class="return"><dt><b>Returns:</b></dt><dd>Number of intervals </dd></dl>
348
<p>Definition at line <a class="el" href="a00089_source.html#l01405">1405</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
350
<p>References <a class="el" href="a00093_source.html#l00592">bm::for_each_block()</a>, and <a class="el" href="a00091_source.html#l00080">bm::set_array_size</a>.</p>
354
<a class="anchor" id="gacd88ed9539553dd93419b7029e8a4584"></a><!-- doxytag: member="bm::export_array" ref="gacd88ed9539553dd93419b7029e8a4584" args="(BV &bv, It first, It last)" -->
355
<div class="memitem">
356
<div class="memproto">
357
<div class="memtemplate">
358
template<class BV , class It > </div>
359
<table class="memname">
361
<td class="memname">void bm::export_array </td>
363
<td class="paramtype">BV & </td>
364
<td class="paramname"> <em>bv</em>, </td>
367
<td class="paramkey"></td>
369
<td class="paramtype">It </td>
370
<td class="paramname"> <em>first</em>, </td>
373
<td class="paramkey"></td>
375
<td class="paramtype">It </td>
376
<td class="paramname"> <em>last</em></td><td> </td>
381
<td></td><td></td><td><code> [inline]</code></td>
387
<p>Export bitset from an array of binary data representing the bit vector. </p>
388
<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>
389
<dl><dt><b>Parameters:</b></dt><dd>
390
<table border="0" cellspacing="2" cellpadding="0">
391
<tr><td valign="top"></td><td valign="top"><em>bv</em> </td><td>- destination bitvector </td></tr>
392
<tr><td valign="top"></td><td valign="top"><em>first</em> </td><td>- first element of the iterated sequence </td></tr>
393
<tr><td valign="top"></td><td valign="top"><em>last</em> </td><td>- last element of the iterated sequence </td></tr>
398
<p>Definition at line <a class="el" href="a00089_source.html#l01431">1431</a> of file <a class="el" href="a00089_source.html">bmalgo_impl.h</a>.</p>
400
<p>References <a class="el" href="a00092_source.html#l00050">BM_ASSERT</a>, <a class="el" href="a00091_source.html#l00116">bm::BM_BIT</a>, <a class="el" href="a00092_source.html#l00095">BMGAP_PTR</a>, <a class="el" href="a00091_source.html#l00052">bm::set_block_size</a>, and <a class="el" href="a00091_source.html#l00083">bm::set_total_blocks</a>.</p>
405
<hr size="1"/><address style="text-align: right;"><small>Generated on Fri Jan 8 20:09:20 2010 for BitMagic by
159
406
<a href="http://www.doxygen.org/index.html">
160
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
407
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>