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

« back to all changes in this revision

Viewing changes to html/a00057.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;::statistics Struct Reference</title>
 
3
<title>BitMagic: sample6.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="a00057.html">statistics</a></div>
10
 
<h1>bm::bvector&lt; Alloc, MS &gt;::statistics Struct Reference<br>
11
 
<small>
12
 
[<a class="el" href="a00095.html">The Main bvector&lt;&gt; Group</a>]</small>
13
 
</h1>Structure with statistical information about bitset's memory allocation details.  
14
 
<a href="#_details">More...</a>
15
 
<p>
16
 
<code>#include &lt;<a class="el" href="a00102.html">bm.h</a>&gt;</code>
17
 
<p>
18
 
<table border="0" cellpadding="0" cellspacing="0">
19
 
<tr><td></td></tr>
20
 
<tr><td colspan="2"><br><h2>Data Fields</h2></td></tr>
21
 
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o0">bit_blocks</a></td></tr>
22
 
 
23
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Number of bit blocks.  <a href="#o0"></a><br></td></tr>
24
 
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o1">gap_blocks</a></td></tr>
25
 
 
26
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Number of GAP blocks.  <a href="#o1"></a><br></td></tr>
27
 
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o2">max_serialize_mem</a></td></tr>
28
 
 
29
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Estimated maximum of memory required for serialization.  <a href="#o2"></a><br></td></tr>
30
 
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o3">memory_used</a></td></tr>
31
 
 
32
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Memory used by bitvector including temp and service blocks.  <a href="#o3"></a><br></td></tr>
33
 
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a19">gap_word_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o4">gap_length</a> [<a class="el" href="a00092.html#a28">bm::set_total_blocks</a>]</td></tr>
34
 
 
35
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Array of all GAP block lengths in the bvector.  <a href="#o4"></a><br></td></tr>
36
 
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a19">gap_word_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00057.html#o5">gap_levels</a> [<a class="el" href="a00092.html#a23">bm::gap_levels</a>]</td></tr>
37
 
 
38
 
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">GAP lengths used by bvector.  <a href="#o5"></a><br></td></tr>
39
 
</table>
40
 
<hr><a name="_details"></a><h2>Detailed Description</h2>
41
 
<h3>template&lt;class Alloc, class MS&gt;<br>
42
 
 struct bm::bvector&lt; Alloc, MS &gt;::statistics</h3>
43
 
 
44
 
Structure with statistical information about bitset's memory allocation details. 
45
 
<p>
46
 
 
47
 
<p>
48
 
Definition at line <a class="el" href="a00102.html#l00121">121</a> of file <a class="el" href="a00102.html">bm.h</a>.<hr><h2>Field Documentation</h2>
49
 
<a class="anchor" name="o0" doxytag="bm::bvector::statistics::bit_blocks"></a><p>
50
 
<table class="mdTable" cellpadding="2" cellspacing="0">
51
 
  <tr>
52
 
    <td class="mdRow">
53
 
      <table cellpadding="0" cellspacing="0" border="0">
54
 
        <tr>
55
 
          <td class="mdPrefix" colspan="4">
56
 
template&lt;class Alloc, class MS&gt; </td>
57
 
        </tr>
58
 
        <tr>
59
 
          <td class="md" nowrap valign="top">unsigned <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o0">statistics::bit_blocks</a>          </td>
60
 
        </tr>
61
 
      </table>
62
 
    </td>
63
 
  </tr>
64
 
</table>
65
 
<table cellspacing="5" cellpadding="0" border="0">
66
 
  <tr>
67
 
    <td>
68
 
      &nbsp;
69
 
    </td>
70
 
    <td>
71
 
 
72
 
<p>
73
 
Number of bit blocks. 
74
 
<p>
75
 
 
76
 
<p>
77
 
Definition at line <a class="el" href="a00102.html#l00124">124</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
78
 
  </tr>
79
 
</table>
80
 
<a class="anchor" name="o1" doxytag="bm::bvector::statistics::gap_blocks"></a><p>
81
 
<table class="mdTable" cellpadding="2" cellspacing="0">
82
 
  <tr>
83
 
    <td class="mdRow">
84
 
      <table cellpadding="0" cellspacing="0" border="0">
85
 
        <tr>
86
 
          <td class="mdPrefix" colspan="4">
87
 
template&lt;class Alloc, class MS&gt; </td>
88
 
        </tr>
89
 
        <tr>
90
 
          <td class="md" nowrap valign="top">unsigned <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o1">statistics::gap_blocks</a>          </td>
91
 
        </tr>
92
 
      </table>
93
 
    </td>
94
 
  </tr>
95
 
</table>
96
 
<table cellspacing="5" cellpadding="0" border="0">
97
 
  <tr>
98
 
    <td>
99
 
      &nbsp;
100
 
    </td>
101
 
    <td>
102
 
 
103
 
<p>
104
 
Number of GAP blocks. 
105
 
<p>
106
 
 
107
 
<p>
108
 
Definition at line <a class="el" href="a00102.html#l00126">126</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
109
 
  </tr>
110
 
</table>
111
 
<a class="anchor" name="o4" doxytag="bm::bvector::statistics::gap_length"></a><p>
112
 
<table class="mdTable" cellpadding="2" cellspacing="0">
113
 
  <tr>
114
 
    <td class="mdRow">
115
 
      <table cellpadding="0" cellspacing="0" border="0">
116
 
        <tr>
117
 
          <td class="mdPrefix" colspan="4">
118
 
template&lt;class Alloc, class MS&gt; </td>
119
 
        </tr>
120
 
        <tr>
121
 
          <td class="md" nowrap valign="top"><a class="el" href="a00092.html#a19">gap_word_t</a> <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o4">statistics::gap_length</a>[<a class="el" href="a00092.html#a28">bm::set_total_blocks</a>]          </td>
122
 
        </tr>
123
 
      </table>
124
 
    </td>
125
 
  </tr>
126
 
</table>
127
 
<table cellspacing="5" cellpadding="0" border="0">
128
 
  <tr>
129
 
    <td>
130
 
      &nbsp;
131
 
    </td>
132
 
    <td>
133
 
 
134
 
<p>
135
 
Array of all GAP block lengths in the bvector. 
136
 
<p>
137
 
 
138
 
<p>
139
 
Definition at line <a class="el" href="a00102.html#l00132">132</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
140
 
  </tr>
141
 
</table>
142
 
<a class="anchor" name="o5" doxytag="bm::bvector::statistics::gap_levels"></a><p>
143
 
<table class="mdTable" cellpadding="2" cellspacing="0">
144
 
  <tr>
145
 
    <td class="mdRow">
146
 
      <table cellpadding="0" cellspacing="0" border="0">
147
 
        <tr>
148
 
          <td class="mdPrefix" colspan="4">
149
 
template&lt;class Alloc, class MS&gt; </td>
150
 
        </tr>
151
 
        <tr>
152
 
          <td class="md" nowrap valign="top"><a class="el" href="a00092.html#a19">gap_word_t</a> <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o5">statistics::gap_levels</a>[<a class="el" href="a00092.html#a23">bm::gap_levels</a>]          </td>
153
 
        </tr>
154
 
      </table>
155
 
    </td>
156
 
  </tr>
157
 
</table>
158
 
<table cellspacing="5" cellpadding="0" border="0">
159
 
  <tr>
160
 
    <td>
161
 
      &nbsp;
162
 
    </td>
163
 
    <td>
164
 
 
165
 
<p>
166
 
GAP lengths used by bvector. 
167
 
<p>
168
 
 
169
 
<p>
170
 
Definition at line <a class="el" href="a00102.html#l00134">134</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
171
 
  </tr>
172
 
</table>
173
 
<a class="anchor" name="o2" doxytag="bm::bvector::statistics::max_serialize_mem"></a><p>
174
 
<table class="mdTable" cellpadding="2" cellspacing="0">
175
 
  <tr>
176
 
    <td class="mdRow">
177
 
      <table cellpadding="0" cellspacing="0" border="0">
178
 
        <tr>
179
 
          <td class="mdPrefix" colspan="4">
180
 
template&lt;class Alloc, class MS&gt; </td>
181
 
        </tr>
182
 
        <tr>
183
 
          <td class="md" nowrap valign="top">unsigned <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o2">statistics::max_serialize_mem</a>          </td>
184
 
        </tr>
185
 
      </table>
186
 
    </td>
187
 
  </tr>
188
 
</table>
189
 
<table cellspacing="5" cellpadding="0" border="0">
190
 
  <tr>
191
 
    <td>
192
 
      &nbsp;
193
 
    </td>
194
 
    <td>
195
 
 
196
 
<p>
197
 
Estimated maximum of memory required for serialization. 
198
 
<p>
199
 
 
200
 
<p>
201
 
Definition at line <a class="el" href="a00102.html#l00128">128</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
202
 
  </tr>
203
 
</table>
204
 
<a class="anchor" name="o3" doxytag="bm::bvector::statistics::memory_used"></a><p>
205
 
<table class="mdTable" cellpadding="2" cellspacing="0">
206
 
  <tr>
207
 
    <td class="mdRow">
208
 
      <table cellpadding="0" cellspacing="0" border="0">
209
 
        <tr>
210
 
          <td class="mdPrefix" colspan="4">
211
 
template&lt;class Alloc, class MS&gt; </td>
212
 
        </tr>
213
 
        <tr>
214
 
          <td class="md" nowrap valign="top">unsigned <a class="el" href="a00048.html">bm::bvector</a>&lt; Alloc, MS &gt;::<a class="el" href="a00057.html#o3">statistics::memory_used</a>          </td>
215
 
        </tr>
216
 
      </table>
217
 
    </td>
218
 
  </tr>
219
 
</table>
220
 
<table cellspacing="5" cellpadding="0" border="0">
221
 
  <tr>
222
 
    <td>
223
 
      &nbsp;
224
 
    </td>
225
 
    <td>
226
 
 
227
 
<p>
228
 
Memory used by bitvector including temp and service blocks. 
229
 
<p>
230
 
 
231
 
<p>
232
 
Definition at line <a class="el" href="a00102.html#l00130">130</a> of file <a class="el" href="a00102.html">bm.h</a>.    </td>
233
 
  </tr>
234
 
</table>
235
 
<hr>The documentation for this struct was generated from the following file:<ul>
236
 
<li><a class="el" href="a00102.html">bm.h</a></ul>
237
 
<hr size="1"><address style="align: right;"><small>Generated on Thu Apr 20 13:29:15 2006 for BitMagic by&nbsp;
 
8
<h1>sample6.cpp</h1>This example demonstrates using of custom memory allocators. In this case allocator works as a memory checker, counts number of allocations and deallocations to make sure that there is no memory leaks.<p>
 
9
For more information please visit: <a href="http://bmagic.sourceforge.net">http://bmagic.sourceforge.net</a><p>
 
10
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
 
11
<span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
 
12
<span class="comment"></span>
 
13
<span class="comment">Permission is hereby granted, free of charge, to any person </span>
 
14
<span class="comment">obtaining a copy of this software and associated documentation </span>
 
15
<span class="comment">files (the "Software"), to deal in the Software without restriction, </span>
 
16
<span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
 
17
<span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
 
18
<span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
 
19
<span class="comment">subject to the following conditions:</span>
 
20
<span class="comment"></span>
 
21
<span class="comment">The above copyright notice and this permission notice shall be included </span>
 
22
<span class="comment">in all copies or substantial portions of the Software.</span>
 
23
<span class="comment"></span>
 
24
<span class="comment">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, </span>
 
25
<span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
 
26
<span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
 
27
<span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
 
28
<span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
 
29
<span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
 
30
<span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
 
31
<span class="comment">*/</span>
 
32
<span class="comment"></span>
 
33
<span class="comment">/** \example sample6.cpp</span>
 
34
<span class="comment"> This example demonstrates using of custom memory allocators.</span>
 
35
<span class="comment"> In this case allocator works as a memory checker, counts number of </span>
 
36
<span class="comment"> allocations and deallocations to make sure that there is no memory leaks. </span>
 
37
<span class="comment"></span>
 
38
<span class="comment">For more information please visit:  http://bmagic.sourceforge.net</span>
 
39
<span class="comment">*/</span>
 
40
 
 
41
<span class="preprocessor">#include &lt;iostream&gt;</span>
 
42
<span class="preprocessor">#include &lt;assert.h&gt;</span>
 
43
<span class="preprocessor">#include "<a class="code" href="a00111.html">bm.h</a>"</span>
 
44
 
 
45
<span class="keyword">using</span> <span class="keyword">namespace </span>std;
 
46
 
 
47
 
 
48
<span class="comment">// Custom allocator keeps number of all alloc/free calls.</span>
 
49
<span class="comment">// It also reservs the front word of the allocated block and saves</span>
 
50
<span class="comment">// number of elements allocated. On deallocation it makes sure</span>
 
51
<span class="comment">// it deallocates the same size as allocated</span>
 
52
 
 
53
<span class="keyword">class </span><a name="_a33"></a><a class="code" href="a00096.html">dbg_block_allocator</a>
 
54
{
 
55
<span class="keyword">public</span>:
 
56
<span class="keyword">static</span> <span class="keywordtype">unsigned</span> na_;
 
57
<span class="keyword">static</span> <span class="keywordtype">unsigned</span> nf_;
 
58
 
 
59
    <span class="keyword">static</span> bm::word_t* allocate(size_t n, <span class="keyword">const</span> <span class="keywordtype">void</span> *)
 
60
    {
 
61
        ++na_;
 
62
        assert(n);
 
63
        bm::word_t* p =
 
64
            (bm::word_t*) ::malloc((n+1) * <span class="keyword">sizeof</span>(bm::word_t));
 
65
        *p = n;
 
66
        <span class="keywordflow">return</span> ++p;
 
67
    }
 
68
 
 
69
    <span class="keyword">static</span> <span class="keywordtype">void</span> deallocate(bm::word_t* p, size_t n)
 
70
    {
 
71
        ++nf_;
 
72
        --p;
 
73
        assert(*p == n);
 
74
        ::free(p);
 
75
    }
 
76
 
 
77
    <span class="keyword">static</span> <span class="keywordtype">int</span> balance()
 
78
    {
 
79
        <span class="keywordflow">return</span> nf_ - na_;
 
80
    }
 
81
};
 
82
 
 
83
<span class="keywordtype">unsigned</span> <a class="code" href="a00096.html#s0">dbg_block_allocator::na_</a> = 0;
 
84
<span class="keywordtype">unsigned</span> <a class="code" href="a00096.html#s1">dbg_block_allocator::nf_</a> = 0;
 
85
 
 
86
<span class="keyword">class </span><a name="_a34"></a><a class="code" href="a00097.html">dbg_ptr_allocator</a>
 
87
{
 
88
<span class="keyword">public</span>:
 
89
<span class="keyword">static</span> <span class="keywordtype">unsigned</span> na_;
 
90
<span class="keyword">static</span> <span class="keywordtype">unsigned</span> nf_;
 
91
 
 
92
    <span class="keyword">static</span> <span class="keywordtype">void</span>* allocate(size_t n, <span class="keyword">const</span> <span class="keywordtype">void</span> *)
 
93
    {
 
94
        ++na_;
 
95
        assert(<span class="keyword">sizeof</span>(size_t) == <span class="keyword">sizeof</span>(<span class="keywordtype">void</span>*));
 
96
        <span class="keywordtype">void</span>* p = ::malloc((n+1) * <span class="keyword">sizeof</span>(<span class="keywordtype">void</span>*));
 
97
        size_t* s = (size_t*) p;
 
98
        *s = n;
 
99
        <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)++s;
 
100
    }
 
101
 
 
102
    <span class="keyword">static</span> <span class="keywordtype">void</span> deallocate(<span class="keywordtype">void</span>* p, size_t n)
 
103
    {
 
104
        ++nf_;
 
105
        size_t* s = (size_t*) p;
 
106
        --s;
 
107
        assert(*s == n);
 
108
        ::free(s);
 
109
    }
 
110
 
 
111
    <span class="keyword">static</span> <span class="keywordtype">int</span> balance()
 
112
    {
 
113
        <span class="keywordflow">return</span> nf_ - na_;
 
114
    }
 
115
 
 
116
};
 
117
 
 
118
<span class="keywordtype">unsigned</span> <a class="code" href="a00097.html#s0">dbg_ptr_allocator::na_</a> = 0;
 
119
<span class="keywordtype">unsigned</span> <a class="code" href="a00097.html#s1">dbg_ptr_allocator::nf_</a> = 0;
 
120
 
 
121
 
 
122
<span class="keyword">typedef</span> bm::mem_alloc&lt;dbg_block_allocator, dbg_ptr_allocator&gt; <a class="code" href="a00125.html#a0">dbg_alloc</a>;
 
123
 
 
124
<span class="keyword">typedef</span> <a name="_a35"></a><a class="code" href="a00084.html">bm::bvector&lt;dbg_alloc&gt;</a> <a class="code" href="a00084.html">bvect</a>;
 
125
 
 
126
 
 
127
 
 
128
<span class="keywordtype">int</span> <a name="a36"></a><a class="code" href="a00120.html#a0">main</a>(<span class="keywordtype">void</span>)
 
129
{
 
130
    {
 
131
        <a class="code" href="a00125.html#a1">bvect</a> bv;
 
132
 
 
133
        bv[10] = <span class="keyword">true</span>;
 
134
        bv[100000] = <span class="keyword">true</span>;
 
135
        bv[10000000] = <span class="keyword">false</span>;
 
136
    }
 
137
 
 
138
    cout &lt;&lt; <span class="stringliteral">"Number of BLOCK allocations = "</span> &lt;&lt;  <a class="code" href="a00096.html#s0">dbg_block_allocator::na_</a> &lt;&lt; endl;
 
139
    cout &lt;&lt; <span class="stringliteral">"Number of PTR allocations = "</span> &lt;&lt;  <a class="code" href="a00097.html#s0">dbg_ptr_allocator::na_</a> &lt;&lt; endl;
 
140
 
 
141
    assert(dbg_block_allocator::balance() == 0);
 
142
    assert(dbg_ptr_allocator::balance() == 0);
 
143
 
 
144
    <span class="keywordflow">return</span> 0;
 
145
}
 
146
 
 
147
  
 
148
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:25 2007 for BitMagic by&nbsp;
238
149
<a href="http://www.doxygen.org/index.html">
239
150
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>
240
151
</body>