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 >::iterator_base::block_descr Union Reference</title>
3
<title>BitMagic: sample3.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="a00052.html">iterator_base</a>::<a class="el" href="a00054.html">block_descr</a></div>
10
<h1>bm::bvector< Alloc, MS >::iterator_base::block_descr Union Reference</h1><code>#include <<a class="el" href="a00102.html">bm.h</a>></code>
12
Collaboration diagram for bm::bvector< Alloc, MS >::iterator_base::block_descr:<p><center><img src="a00175.png" border="0" usemap="#a00176" alt="Collaboration graph"></center>
14
<area href="a00055.html" shape="rect" coords="7,16,319,37" alt="">
15
<area href="a00053.html" shape="rect" coords="343,16,671,37" alt="">
17
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><table border="0" cellpadding="0" cellspacing="0">
19
<tr><td colspan="2"><br><h2>Data Fields</h2></td></tr>
20
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00053.html">bitblock_descr</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00054.html#o0">bit_</a></td></tr>
22
<tr><td class="mdescLeft"> </td><td class="mdescRight">BitBlock related info. <a href="#o0"></a><br></td></tr>
23
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00055.html">dgap_descr</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00054.html#o1">gap_</a></td></tr>
25
<tr><td class="mdescLeft"> </td><td class="mdescRight">DGAP block related info. <a href="#o1"></a><br></td></tr>
27
<hr><a name="_details"></a><h2>Detailed Description</h2>
28
<h3>template<class Alloc, class MS><br>
29
union bm::bvector< Alloc, MS >::iterator_base::block_descr</h3>
31
Block type dependent information for current block.
35
Definition at line <a class="el" href="a00102.html#l00317">317</a> of file <a class="el" href="a00102.html">bm.h</a>.<hr><h2>Field Documentation</h2>
36
<a class="anchor" name="o0" doxytag="bm::bvector::iterator_base::block_descr::bit_"></a><p>
37
<table class="mdTable" cellpadding="2" cellspacing="0">
40
<table cellpadding="0" cellspacing="0" border="0">
42
<td class="mdPrefix" colspan="4">
43
template<class Alloc, class MS> </td>
46
<td class="md" nowrap valign="top"><a class="el" href="a00053.html">bitblock_descr</a> <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::<a class="el" href="a00054.html#o0">iterator_base::block_descr::bit_</a> </td>
52
<table cellspacing="5" cellpadding="0" border="0">
60
BitBlock related info.
64
Definition at line <a class="el" href="a00102.html#l00319">319</a> of file <a class="el" href="a00102.html">bm.h</a>.
66
Referenced by <a class="el" href="a00102.html#l00499">bm::bvector< Alloc, MS >::enumerator::go_up()</a>. </td>
69
<a class="anchor" name="o1" doxytag="bm::bvector::iterator_base::block_descr::gap_"></a><p>
70
<table class="mdTable" cellpadding="2" cellspacing="0">
73
<table cellpadding="0" cellspacing="0" border="0">
75
<td class="mdPrefix" colspan="4">
76
template<class Alloc, class MS> </td>
79
<td class="md" nowrap valign="top"><a class="el" href="a00055.html">dgap_descr</a> <a class="el" href="a00048.html">bm::bvector</a>< Alloc, MS >::<a class="el" href="a00054.html#o1">iterator_base::block_descr::gap_</a> </td>
85
<table cellspacing="5" cellpadding="0" border="0">
93
DGAP block related info.
97
Definition at line <a class="el" href="a00102.html#l00320">320</a> of file <a class="el" href="a00102.html">bm.h</a>.
99
Referenced by <a class="el" href="a00102.html#l00499">bm::bvector< Alloc, MS >::enumerator::go_up()</a>. </td>
102
<hr>The documentation for this union was generated from the following file:<ul>
103
<li><a class="el" href="a00102.html">bm.h</a></ul>
104
<hr size="1"><address style="align: right;"><small>Generated on Thu Apr 20 13:29:15 2006 for BitMagic by
8
<h1>sample3.cpp</h1>Exmaple demonstrates using bitvectors with different initial block allocation strategy. Bitvector 1 (bv1) by default working without RLE compression option (best performance, maximum memory consumption). Bitvector 2 (bv2) will be working in compression mode and use less memory.<p>
9
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00084.html#a52">bm::bvector<>::set_new_blocks_strat()</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 sample3.cpp</span>
35
<span class="comment"> Exmaple demonstrates using bitvectors with different initial</span>
36
<span class="comment"> block allocation strategy. </span>
37
<span class="comment"> Bitvector 1 (bv1) by default working without RLE compression option</span>
38
<span class="comment"> (best performance, maximum memory consumption). </span>
39
<span class="comment"> Bitvector 2 (bv2) will be working in compression mode and use less memory.</span>
40
<span class="comment"> </span>
41
<span class="comment"> \sa bm::bvector<>::set_new_blocks_strat() </span>
42
<span class="comment"></span>
43
<span class="comment"> For more information please visit: http://bmagic.sourceforge.net</span>
44
<span class="comment"></span>
45
<span class="comment">*/</span>
47
<span class="preprocessor">#include <stdlib.h></span>
48
<span class="preprocessor">#include <iostream></span>
49
<span class="preprocessor">#include "<a class="code" href="a00111.html">bm.h</a>"</span>
51
<span class="keyword">using</span> <span class="keyword">namespace </span>std;
53
<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00122.html#a0">MAX_VALUE</a> = 1000000;
55
<span class="comment">// This procedure creates very dense bitvectors.</span>
56
<span class="comment">// The resulting set will consists mostly from ON (1) bits</span>
57
<span class="comment">// interrupted with small gaps of 0 bits.</span>
59
<span class="keywordtype">void</span> <a name="a12"></a><a class="code" href="a00122.html#a1">fill_bvector</a>(<a name="_a13"></a><a class="code" href="a00084.html">bm::bvector<></a>* bv1, <a class="code" href="a00084.html">bm::bvector<></a>* bv2)
61
<span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < MAX_VALUE; ++i)
63
<span class="keywordflow">if</span> (rand() % 2500)
72
<span class="keywordtype">void</span> <a name="a14"></a><a class="code" href="a00122.html#a2">print_statistics</a>(<span class="keyword">const</span> <a class="code" href="a00084.html">bm::bvector<></a>& bv)
74
<a class="code" href="a00084.html">bm::bvector<></a>::statistics st;
75
bv.calc_stat(&st);
77
cout << <span class="stringliteral">"Bits count:"</span> << bv.count() << endl;
78
cout << <span class="stringliteral">"Bit blocks:"</span> << st.bit_blocks << endl;
79
cout << <span class="stringliteral">"GAP blocks:"</span> << st.gap_blocks << endl;
80
cout << <span class="stringliteral">"Memory used:"</span><< st.memory_used << endl;
81
cout << <span class="stringliteral">"Max.serialize mem.:"</span> << st.max_serialize_mem << endl << endl;;
85
<span class="keywordtype">int</span> <a name="a15"></a><a class="code" href="a00120.html#a0">main</a>(<span class="keywordtype">void</span>)
87
<a class="code" href="a00084.html">bm::bvector<></a> bv1;
88
<a class="code" href="a00084.html">bm::bvector<></a> bv2;
90
bv2.<a name="a16"></a><a class="code" href="a00084.html#a52">set_new_blocks_strat</a>(bm::BM_GAP); <span class="comment">// set DGAP compression mode ON</span>
92
<a class="code" href="a00122.html#a1">fill_bvector</a>(&bv1, &bv2); <span class="comment">// Fill both bvectors with the same values</span>
94
<span class="comment">// For a given distrubution statistics should demonstrate</span>
95
<span class="comment">// lower memory consumption for the vector with compression</span>
97
<a class="code" href="a00122.html#a2">print_statistics</a>(bv1);
98
<a class="code" href="a00122.html#a2">print_statistics</a>(bv2);
100
<span class="comment">// Now run optimization procedure for bv1 and see statistics.</span>
102
bv1.<a name="a17"></a><a class="code" href="a00084.html#a55">optimize</a>();
104
<a class="code" href="a00122.html#a2">print_statistics</a>(bv1);
106
<span class="keywordflow">return</span> 0;
109
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:25 2007 for BitMagic by
105
110
<a href="http://www.doxygen.org/index.html">
106
111
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>