~ubuntu-branches/ubuntu/jaunty/bmagic/jaunty

« back to all changes in this revision

Viewing changes to html/a00054.html

  • Committer: Bazaar Package Importer
  • Author(s): Andres Salomon
  • Date: 2008-01-05 23:58:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080105235856-2kmxhxkz14qjy9ia
Tags: 3.5.0-1
* New upstream release.
* Add tcpp.dpatch.  This stops tests/stress/t.cpp from including
  ncbi_pch.hpp.  As far as I can tell, NCBI is not used at all, I have
  no idea where that came from..
* Silence some lintian warnings; binary-arch-rules-but-pkg-is-arch-indep
  and ancient-standards-version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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&lt; Alloc, MS &gt;::iterator_base::block_descr Union Reference</title>
 
3
<title>BitMagic: sample3.cpp</title>
4
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
5
</head><body>
6
6
<!-- Generated by Doxygen 1.4.1 -->
7
7
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;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&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="examples.html">Examples</a></div>
8
 
<div class="nav">
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&lt; Alloc, MS &gt;::iterator_base::block_descr Union Reference</h1><code>#include &lt;<a class="el" href="a00102.html">bm.h</a>&gt;</code>
11
 
<p>
12
 
Collaboration diagram for bm::bvector&lt; Alloc, MS &gt;::iterator_base::block_descr:<p><center><img src="a00175.png" border="0" usemap="#a00176" alt="Collaboration graph"></center>
13
 
<map name="a00176">
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="">
16
 
</map>
17
 
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><table border="0" cellpadding="0" cellspacing="0">
18
 
<tr><td></td></tr>
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>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00054.html#o0">bit_</a></td></tr>
21
 
 
22
 
<tr><td class="mdescLeft">&nbsp;</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>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00054.html#o1">gap_</a></td></tr>
24
 
 
25
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">DGAP block related info.  <a href="#o1"></a><br></td></tr>
26
 
</table>
27
 
<hr><a name="_details"></a><h2>Detailed Description</h2>
28
 
<h3>template&lt;class Alloc, class MS&gt;<br>
29
 
 union bm::bvector&lt; Alloc, MS &gt;::iterator_base::block_descr</h3>
30
 
 
31
 
Block type dependent information for current block. 
32
 
<p>
33
 
 
34
 
<p>
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">
38
 
  <tr>
39
 
    <td class="mdRow">
40
 
      <table cellpadding="0" cellspacing="0" border="0">
41
 
        <tr>
42
 
          <td class="mdPrefix" colspan="4">
43
 
template&lt;class Alloc, class MS&gt; </td>
44
 
        </tr>
45
 
        <tr>
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>&lt; Alloc, MS &gt;::<a class="el" href="a00054.html#o0">iterator_base::block_descr::bit_</a>          </td>
47
 
        </tr>
48
 
      </table>
49
 
    </td>
50
 
  </tr>
51
 
</table>
52
 
<table cellspacing="5" cellpadding="0" border="0">
53
 
  <tr>
54
 
    <td>
55
 
      &nbsp;
56
 
    </td>
57
 
    <td>
58
 
 
59
 
<p>
60
 
BitBlock related info. 
61
 
<p>
62
 
 
63
 
<p>
64
 
Definition at line <a class="el" href="a00102.html#l00319">319</a> of file <a class="el" href="a00102.html">bm.h</a>.
65
 
<p>
66
 
Referenced by <a class="el" href="a00102.html#l00499">bm::bvector&lt; Alloc, MS &gt;::enumerator::go_up()</a>.    </td>
67
 
  </tr>
68
 
</table>
69
 
<a class="anchor" name="o1" doxytag="bm::bvector::iterator_base::block_descr::gap_"></a><p>
70
 
<table class="mdTable" cellpadding="2" cellspacing="0">
71
 
  <tr>
72
 
    <td class="mdRow">
73
 
      <table cellpadding="0" cellspacing="0" border="0">
74
 
        <tr>
75
 
          <td class="mdPrefix" colspan="4">
76
 
template&lt;class Alloc, class MS&gt; </td>
77
 
        </tr>
78
 
        <tr>
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>&lt; Alloc, MS &gt;::<a class="el" href="a00054.html#o1">iterator_base::block_descr::gap_</a>          </td>
80
 
        </tr>
81
 
      </table>
82
 
    </td>
83
 
  </tr>
84
 
</table>
85
 
<table cellspacing="5" cellpadding="0" border="0">
86
 
  <tr>
87
 
    <td>
88
 
      &nbsp;
89
 
    </td>
90
 
    <td>
91
 
 
92
 
<p>
93
 
DGAP block related info. 
94
 
<p>
95
 
 
96
 
<p>
97
 
Definition at line <a class="el" href="a00102.html#l00320">320</a> of file <a class="el" href="a00102.html">bm.h</a>.
98
 
<p>
99
 
Referenced by <a class="el" href="a00102.html#l00499">bm::bvector&lt; Alloc, MS &gt;::enumerator::go_up()</a>.    </td>
100
 
  </tr>
101
 
</table>
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&nbsp;
 
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&lt;&gt;::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&lt;&gt;::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>
 
46
 
 
47
<span class="preprocessor">#include &lt;stdlib.h&gt;</span>
 
48
<span class="preprocessor">#include &lt;iostream&gt;</span>
 
49
<span class="preprocessor">#include "<a class="code" href="a00111.html">bm.h</a>"</span>
 
50
 
 
51
<span class="keyword">using</span> <span class="keyword">namespace </span>std;
 
52
 
 
53
<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00122.html#a0">MAX_VALUE</a> = 1000000;
 
54
 
 
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>
 
58
 
 
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&lt;&gt;</a>* bv1, <a class="code" href="a00084.html">bm::bvector&lt;&gt;</a>* bv2)
 
60
{
 
61
    <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; MAX_VALUE; ++i)
 
62
    {
 
63
        <span class="keywordflow">if</span> (rand() % 2500)
 
64
        {
 
65
            bv1-&gt;set_bit(i);
 
66
            bv2-&gt;set_bit(i);
 
67
        }
 
68
    }
 
69
}
 
70
 
 
71
 
 
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&lt;&gt;</a>&amp; bv)
 
73
{
 
74
    <a class="code" href="a00084.html">bm::bvector&lt;&gt;</a>::statistics st;
 
75
    bv.calc_stat(&amp;st);
 
76
 
 
77
    cout &lt;&lt; <span class="stringliteral">"Bits count:"</span> &lt;&lt; bv.count() &lt;&lt; endl;
 
78
    cout &lt;&lt; <span class="stringliteral">"Bit blocks:"</span> &lt;&lt; st.bit_blocks &lt;&lt; endl;
 
79
    cout &lt;&lt; <span class="stringliteral">"GAP blocks:"</span> &lt;&lt; st.gap_blocks &lt;&lt; endl;
 
80
    cout &lt;&lt; <span class="stringliteral">"Memory used:"</span>&lt;&lt; st.memory_used &lt;&lt; endl;
 
81
    cout &lt;&lt; <span class="stringliteral">"Max.serialize mem.:"</span> &lt;&lt; st.max_serialize_mem &lt;&lt; endl &lt;&lt; endl;;
 
82
}
 
83
 
 
84
 
 
85
<span class="keywordtype">int</span> <a name="a15"></a><a class="code" href="a00120.html#a0">main</a>(<span class="keywordtype">void</span>)
 
86
{
 
87
    <a class="code" href="a00084.html">bm::bvector&lt;&gt;</a>   bv1;    
 
88
    <a class="code" href="a00084.html">bm::bvector&lt;&gt;</a>   bv2;
 
89
 
 
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>
 
91
 
 
92
    <a class="code" href="a00122.html#a1">fill_bvector</a>(&amp;bv1, &amp;bv2);  <span class="comment">// Fill both bvectors with the same values</span>
 
93
 
 
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>
 
96
 
 
97
    <a class="code" href="a00122.html#a2">print_statistics</a>(bv1);    
 
98
    <a class="code" href="a00122.html#a2">print_statistics</a>(bv2);
 
99
 
 
100
    <span class="comment">// Now run optimization procedure for bv1 and see statistics.</span>
 
101
 
 
102
    bv1.<a name="a17"></a><a class="code" href="a00084.html#a55">optimize</a>();
 
103
 
 
104
    <a class="code" href="a00122.html#a2">print_statistics</a>(bv1);    
 
105
 
 
106
    <span class="keywordflow">return</span> 0;
 
107
}
 
108
 
 
109
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:25 2007 for BitMagic by&nbsp;
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>
107
112
</body>