~ubuntu-branches/ubuntu/trusty/bmagic/trusty

« back to all changes in this revision

Viewing changes to doc/html/a00107_source.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2009-12-09 16:02:55 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091209160255-hu2bnjrbncl92z5w
Tags: 3.6.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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">
 
3
<head>
 
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
 
5
<title>BitMagic: sample7.cpp Source File</title>
 
6
<link href="tabs.css" rel="stylesheet" type="text/css"/>
 
7
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
 
8
</head>
 
9
<body>
 
10
<!-- Generated by Doxygen 1.6.1 -->
 
11
<div class="navigation" id="top">
 
12
  <div class="tabs">
 
13
    <ul>
 
14
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
 
15
      <li><a href="modules.html"><span>Modules</span></a></li>
 
16
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
 
17
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
 
18
      <li class="current"><a href="files.html"><span>Files</span></a></li>
 
19
      <li><a href="examples.html"><span>Examples</span></a></li>
 
20
    </ul>
 
21
  </div>
 
22
  <div class="tabs">
 
23
    <ul>
 
24
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
 
25
      <li><a href="globals.html"><span>Globals</span></a></li>
 
26
    </ul>
 
27
  </div>
 
28
<h1>sample7.cpp</h1><a href="a00107.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
 
29
<a name="l00002"></a>00002 <span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
 
30
<a name="l00003"></a>00003 <span class="comment"></span>
 
31
<a name="l00004"></a>00004 <span class="comment">Permission is hereby granted, free of charge, to any person </span>
 
32
<a name="l00005"></a>00005 <span class="comment">obtaining a copy of this software and associated documentation </span>
 
33
<a name="l00006"></a>00006 <span class="comment">files (the &quot;Software&quot;), to deal in the Software without restriction, </span>
 
34
<a name="l00007"></a>00007 <span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
 
35
<a name="l00008"></a>00008 <span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
 
36
<a name="l00009"></a>00009 <span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
 
37
<a name="l00010"></a>00010 <span class="comment">subject to the following conditions:</span>
 
38
<a name="l00011"></a>00011 <span class="comment"></span>
 
39
<a name="l00012"></a>00012 <span class="comment">The above copyright notice and this permission notice shall be included </span>
 
40
<a name="l00013"></a>00013 <span class="comment">in all copies or substantial portions of the Software.</span>
 
41
<a name="l00014"></a>00014 <span class="comment"></span>
 
42
<a name="l00015"></a>00015 <span class="comment">THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, </span>
 
43
<a name="l00016"></a>00016 <span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
 
44
<a name="l00017"></a>00017 <span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
 
45
<a name="l00018"></a>00018 <span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
 
46
<a name="l00019"></a>00019 <span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
 
47
<a name="l00020"></a>00020 <span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
 
48
<a name="l00021"></a>00021 <span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
 
49
<a name="l00022"></a>00022 <span class="comment">*/</span>
 
50
<a name="l00023"></a>00023 <span class="comment"></span>
 
51
<a name="l00024"></a>00024 <span class="comment">/*! @example sample7.cpp</span>
 
52
<a name="l00025"></a>00025 <span class="comment"> This example demonstrates using of memory save mode of bitset operations.</span>
 
53
<a name="l00026"></a>00026 <span class="comment"></span>
 
54
<a name="l00027"></a>00027 <span class="comment">For more information please visit:  http://bmagic.sourceforge.net</span>
 
55
<a name="l00028"></a>00028 <span class="comment"></span>
 
56
<a name="l00029"></a>00029 <span class="comment">*/</span>
 
57
<a name="l00030"></a>00030 <span class="comment"></span>
 
58
<a name="l00031"></a>00031 <span class="comment">/*! @file</span>
 
59
<a name="l00032"></a>00032 <span class="comment">    @ingroup mset</span>
 
60
<a name="l00033"></a>00033 <span class="comment">*/</span>
 
61
<a name="l00034"></a>00034 
 
62
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;iostream&gt;</span>
 
63
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
 
64
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
 
65
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;time.h&gt;</span>
 
66
<a name="l00039"></a>00039 
 
67
<a name="l00040"></a>00040 
 
68
<a name="l00041"></a>00041 <span class="comment">// BM library version 3.1.3 and later can keep internal bit flags in pointers.</span>
 
69
<a name="l00042"></a>00042 <span class="comment">// This is efficient but not completely portable hack. </span>
 
70
<a name="l00043"></a>00043 <span class="comment">// For compatibility it can be disabled it by defining BM_DISBALE_BIT_IN_PTR.</span>
 
71
<a name="l00044"></a>00044 <span class="comment">// If you do not disable bits in pointer the second template parameter of bvector</span>
 
72
<a name="l00045"></a>00045 <span class="comment">// is simply ignored and portion of this example is becoming irrelevant.</span>
 
73
<a name="l00046"></a><a class="code" href="a00107.html#afd28a76a99d71528ccf3244e6cda5f6f">00046</a> <span class="preprocessor">#define BM_DISBALE_BIT_IN_PTR</span>
 
74
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="a00084.html">bm.h</a>&quot;</span>
 
75
<a name="l00048"></a>00048 
 
76
<a name="l00049"></a>00049 <span class="keyword">using namespace </span>std;
 
77
<a name="l00050"></a>00050 
 
78
<a name="l00051"></a>00051 <span class="comment">// Customized bitvector uses standard memory allocator and uses</span>
 
79
<a name="l00052"></a>00052 <span class="comment">// an alternative implementation of internal set. Saves memory when we </span>
 
80
<a name="l00053"></a>00053 <span class="comment">// work with sparse or dense bitsets.</span>
 
81
<a name="l00054"></a>00054 <span class="keyword">typedef</span> <a class="code" href="a00043.html" title="bitvector with runtime compression of bits.">bm::bvector</a>&lt;<a class="code" href="a00073.html" title="BM style allocator adapter.">bm::standard_allocator</a>, 
 
82
<a name="l00055"></a><a class="code" href="a00107.html#aa1d04e6b5b41cdd26a1474e7a28dac78">00055</a>                     <a class="code" href="a00074.html" title="Template class implements memory saving set functionality.">bm::miniset&lt;bm::block_allocator, bm::set_total_blocks&gt;</a> &gt; <a class="code" href="a00043.html" title="bitvector with runtime compression of bits.">bvect</a>;
 
83
<a name="l00056"></a>00056 
 
84
<a name="l00057"></a>00057 
 
85
<a name="l00058"></a><a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">00058</a> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a> = 10000;
 
86
<a name="l00059"></a><a class="code" href="a00107.html#a0be29ed34efa43589f6c14e4e9f5dbc4">00059</a> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00107.html#a0be29ed34efa43589f6c14e4e9f5dbc4">randombits</a> = 150;
 
87
<a name="l00060"></a><a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">00060</a> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">maxbit</a> = 100000000;
 
88
<a name="l00061"></a>00061 
 
89
<a name="l00062"></a><a class="code" href="a00107.html#aef9a3bedb74930ffc25d49f7ac4ba1eb">00062</a> bvect*  <a class="code" href="a00107.html#aef9a3bedb74930ffc25d49f7ac4ba1eb">bitsets</a>[<a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>];
 
90
<a name="l00063"></a>00063 
 
91
<a name="l00064"></a>00064 <span class="comment">// ---------------------------------------------------------</span>
 
92
<a name="l00065"></a>00065 
 
93
<a name="l00066"></a><a class="code" href="a00107.html#adb34fb3c04bbc949324b069298b6ad60">00066</a> <span class="keywordtype">void</span> <a class="code" href="a00107.html#adb34fb3c04bbc949324b069298b6ad60">CreateSets</a>()
 
94
<a name="l00067"></a>00067 {
 
95
<a name="l00068"></a>00068     <span class="keywordtype">unsigned</span> mu = 0;
 
96
<a name="l00069"></a>00069     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>; ++i)
 
97
<a name="l00070"></a>00070     {
 
98
<a name="l00071"></a>00071         <span class="keywordflow">if</span> ((i % 100) == 0) { cout &lt;&lt; <span class="stringliteral">&quot;.&quot;</span>; cout.flush(); }
 
99
<a name="l00072"></a>00072         <span class="comment">// create bitvector using in GAP mode using an alternative</span>
 
100
<a name="l00073"></a>00073         <span class="comment">// GAP levels table (minimalistic).</span>
 
101
<a name="l00074"></a>00074         bitsets[i] = 
 
102
<a name="l00075"></a>00075             <span class="keyword">new</span> <a class="code" href="a00106.html#ac07bb102df543a0c581493c5f35b2129">bvect</a>(<a class="code" href="a00113.html#ggad0b87b3b7292383a864d27feaf1c9effa7fe09d1d7c62a813db922c396c0cbc9c" title="GAP compression is ON.">bm::BM_GAP</a>, <a class="code" href="a00067.html" title="Alternative GAP lengths table. Good for for memory saver mode and very sparse bitsets...">bm::gap_len_table_min&lt;true&gt;::_len</a>, <a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">maxbit</a>);
 
103
<a name="l00076"></a>00076         bvect&amp; bv = *bitsets[i];
 
104
<a name="l00077"></a>00077         <a class="code" href="a00082.html" title="Statistical information about bitset&amp;#39;s memory allocation details.">bvect::statistics</a> st;
 
105
<a name="l00078"></a>00078         bv.<a class="code" href="a00043.html#a1eaaac76a97b9eb1d3c11f21cf9385ac" title="Calculates bitvector statistics.">calc_stat</a>(&amp;st);
 
106
<a name="l00079"></a>00079         mu += st.<a class="code" href="a00042.html#ad3b2190eb4afe24ecd56323cbc0a7666" title="Memory used by bitvector including temp and service blocks.">memory_used</a>;
 
107
<a name="l00080"></a>00080     }
 
108
<a name="l00081"></a>00081     cout &lt;&lt; endl &lt;&lt; <span class="stringliteral">&quot;Created &quot;</span> &lt;&lt; setscount &lt;&lt; <span class="stringliteral">&quot; sets.&quot;</span> &lt;&lt; endl; 
 
109
<a name="l00082"></a>00082     cout &lt;&lt; <span class="stringliteral">&quot;Used &quot;</span> &lt;&lt; mu / (1024*1024)&lt;&lt; <span class="stringliteral">&quot; MB.&quot;</span> &lt;&lt; endl;
 
110
<a name="l00083"></a>00083 }
 
111
<a name="l00084"></a>00084 
 
112
<a name="l00085"></a>00085 <span class="comment">// ---------------------------------------------------------</span>
 
113
<a name="l00086"></a>00086 
 
114
<a name="l00087"></a><a class="code" href="a00107.html#a8b36b27c3c40d9e559c078673a3a4dc9">00087</a> <span class="keywordtype">void</span> <a class="code" href="a00107.html#a8b36b27c3c40d9e559c078673a3a4dc9">FillSets</a>()
 
115
<a name="l00088"></a>00088 {
 
116
<a name="l00089"></a>00089     <span class="keywordtype">unsigned</span> mu, bit_blocks, gap_blocks;
 
117
<a name="l00090"></a>00090     cout &lt;&lt; <span class="stringliteral">&quot;Filling sets...&quot;</span>;
 
118
<a name="l00091"></a>00091     mu = bit_blocks = gap_blocks = 0;
 
119
<a name="l00092"></a>00092     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>; ++i)
 
120
<a name="l00093"></a>00093     {
 
121
<a name="l00094"></a>00094         <span class="keywordflow">if</span> ((i % 100) == 0) { cout &lt;&lt; <span class="stringliteral">&quot;.&quot;</span>; cout.flush(); }
 
122
<a name="l00095"></a>00095         <span class="keywordflow">if</span> ((i % 3) == 0) <span class="keywordflow">continue</span>;
 
123
<a name="l00096"></a>00096         bvect&amp; bv = *bitsets[i];
 
124
<a name="l00097"></a>00097         <span class="keywordtype">unsigned</span> bn = 0;
 
125
<a name="l00098"></a>00098         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j &lt; <a class="code" href="a00107.html#a0be29ed34efa43589f6c14e4e9f5dbc4">randombits</a>; j+=3)
 
126
<a name="l00099"></a>00099         {
 
127
<a name="l00100"></a>00100             bn += (<a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">maxbit</a> / randombits) + rand() % 10;
 
128
<a name="l00101"></a>00101             <span class="keywordflow">if</span> (bn &gt; <a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">maxbit</a>) bn = rand() % <a class="code" href="a00107.html#a1b239e2f0f190ff4df0b359f8b601644">maxbit</a>;
 
129
<a name="l00102"></a>00102 
 
130
<a name="l00103"></a>00103             bv[bn] = <span class="keyword">true</span>;
 
131
<a name="l00104"></a>00104             bv[bn+1] = <span class="keyword">true</span>;
 
132
<a name="l00105"></a>00105             bv[bn+2] = <span class="keyword">true</span>;
 
133
<a name="l00106"></a>00106         }
 
134
<a name="l00107"></a>00107         <a class="code" href="a00082.html" title="Statistical information about bitset&amp;#39;s memory allocation details.">bvect::statistics</a> st;
 
135
<a name="l00108"></a>00108         bv.<a class="code" href="a00043.html#a1eaaac76a97b9eb1d3c11f21cf9385ac" title="Calculates bitvector statistics.">calc_stat</a>(&amp;st);
 
136
<a name="l00109"></a>00109         mu += st.<a class="code" href="a00042.html#ad3b2190eb4afe24ecd56323cbc0a7666" title="Memory used by bitvector including temp and service blocks.">memory_used</a>;
 
137
<a name="l00110"></a>00110         bit_blocks += st.<a class="code" href="a00042.html#a4ec8ba190b4ba31c431c008402881c62" title="Number of bit blocks.">bit_blocks</a>;
 
138
<a name="l00111"></a>00111         gap_blocks += st.<a class="code" href="a00042.html#a4dcfd64e9ab0be5472e3c2b04e551f81" title="Number of GAP blocks.">gap_blocks</a>;
 
139
<a name="l00112"></a>00112     }
 
140
<a name="l00113"></a>00113     cout &lt;&lt; endl &lt;&lt; <span class="stringliteral">&quot;Used &quot;</span> &lt;&lt; mu / (1024*1024)&lt;&lt; <span class="stringliteral">&quot; MB.&quot;</span> &lt;&lt; endl;
 
141
<a name="l00114"></a>00114 
 
142
<a name="l00115"></a>00115     cout &lt;&lt; <span class="stringliteral">&quot;BIT Blocks=&quot;</span> &lt;&lt; bit_blocks &lt;&lt; endl;
 
143
<a name="l00116"></a>00116     cout &lt;&lt; <span class="stringliteral">&quot;GAP Blocks=&quot;</span> &lt;&lt; gap_blocks &lt;&lt; endl;
 
144
<a name="l00117"></a>00117 }
 
145
<a name="l00118"></a>00118 
 
146
<a name="l00119"></a>00119 <span class="comment">// ---------------------------------------------------------</span>
 
147
<a name="l00120"></a>00120 
 
148
<a name="l00121"></a><a class="code" href="a00107.html#a5cb27a7766b9e7c1ea79b2741714b404">00121</a> <span class="keywordtype">void</span> <a class="code" href="a00107.html#a5cb27a7766b9e7c1ea79b2741714b404">EnumerateSets</a>()
 
149
<a name="l00122"></a>00122 {
 
150
<a name="l00123"></a>00123     cout &lt;&lt; <span class="stringliteral">&quot;Enumerating sets...&quot;</span>;
 
151
<a name="l00124"></a>00124     <span class="keywordtype">unsigned</span> bitcnt = 0;
 
152
<a name="l00125"></a>00125     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>; ++i)
 
153
<a name="l00126"></a>00126     {
 
154
<a name="l00127"></a>00127         <span class="keywordflow">if</span> ((i % 100) == 0) { cout &lt;&lt; <span class="stringliteral">&quot;.&quot;</span>; cout.flush(); }
 
155
<a name="l00128"></a>00128         bvect&amp; bv = *bitsets[i];
 
156
<a name="l00129"></a>00129 
 
157
<a name="l00130"></a>00130         <a class="code" href="a00062.html" title="Constant input iterator designed to enumerate &amp;quot;ON&amp;quot; bits.">bvect::enumerator</a> en = bv.<a class="code" href="a00043.html#aad48c661f843e32c9893438a6f27a8f0" title="Returns enumerator pointing on the first non-zero bit.">first</a>();
 
158
<a name="l00131"></a>00131         <a class="code" href="a00062.html" title="Constant input iterator designed to enumerate &amp;quot;ON&amp;quot; bits.">bvect::enumerator</a> en_end = bv.<a class="code" href="a00043.html#a2c6e522f858fdc466765d2c0f269f590" title="Returns enumerator pointing on the next bit after the last.">end</a>();
 
159
<a name="l00132"></a>00132 
 
160
<a name="l00133"></a>00133         <span class="keywordflow">for</span> (;en &lt; en_end; ++en)
 
161
<a name="l00134"></a>00134         {
 
162
<a name="l00135"></a>00135             ++bitcnt;
 
163
<a name="l00136"></a>00136         }
 
164
<a name="l00137"></a>00137     }
 
165
<a name="l00138"></a>00138     cout &lt;&lt; endl &lt;&lt; bitcnt &lt;&lt; endl;
 
166
<a name="l00139"></a>00139 }
 
167
<a name="l00140"></a>00140 
 
168
<a name="l00141"></a>00141 <span class="comment">// ---------------------------------------------------------</span>
 
169
<a name="l00142"></a>00142 
 
170
<a name="l00143"></a><a class="code" href="a00107.html#aa777f579687be6096cdbb8b2d70baf6e">00143</a> <span class="keywordtype">void</span> <a class="code" href="a00107.html#aa777f579687be6096cdbb8b2d70baf6e">DestroySets</a>()
 
171
<a name="l00144"></a>00144 {
 
172
<a name="l00145"></a>00145     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>; ++i)
 
173
<a name="l00146"></a>00146     {
 
174
<a name="l00147"></a>00147         <span class="keyword">delete</span> bitsets[i];
 
175
<a name="l00148"></a>00148     }
 
176
<a name="l00149"></a>00149 }
 
177
<a name="l00150"></a>00150 
 
178
<a name="l00151"></a>00151 <span class="comment">// ---------------------------------------------------------</span>
 
179
<a name="l00152"></a>00152 
 
180
<a name="l00153"></a><a class="code" href="a00107.html#a1bdd608971ec7ea3d5c76cf21c7d92e7">00153</a> <span class="keywordtype">void</span> <a class="code" href="a00107.html#a1bdd608971ec7ea3d5c76cf21c7d92e7">OrSets</a>()
 
181
<a name="l00154"></a>00154 {
 
182
<a name="l00155"></a>00155     bvect res;
 
183
<a name="l00156"></a>00156     cout &lt;&lt; <span class="stringliteral">&quot;Calculating Or...&quot;</span>;
 
184
<a name="l00157"></a>00157     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>; ++i)
 
185
<a name="l00158"></a>00158     {
 
186
<a name="l00159"></a>00159         <span class="keywordflow">if</span> ((i % 100) == 0) { cout &lt;&lt; <span class="stringliteral">&quot;.&quot;</span>; cout.flush(); }
 
187
<a name="l00160"></a>00160         <span class="keyword">const</span> bvect&amp; bv = *bitsets[i];
 
188
<a name="l00161"></a>00161 
 
189
<a name="l00162"></a>00162         res |= bv;
 
190
<a name="l00163"></a>00163     }
 
191
<a name="l00164"></a>00164     cout &lt;&lt; endl &lt;&lt; res.<a class="code" href="a00043.html#a71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() &lt;&lt; endl;
 
192
<a name="l00165"></a>00165 }
 
193
<a name="l00166"></a>00166 
 
194
<a name="l00167"></a>00167 <span class="comment">// ---------------------------------------------------------</span>
 
195
<a name="l00168"></a>00168 
 
196
<a name="l00169"></a>00169 
 
197
<a name="l00170"></a>00170 
 
198
<a name="l00171"></a><a class="code" href="a00107.html#a840291bc02cba5474a4cb46a9b9566fe">00171</a> <span class="keywordtype">int</span> <a class="code" href="a00101.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
 
199
<a name="l00172"></a>00172 {
 
200
<a name="l00173"></a>00173     time_t start_time = time(0);
 
201
<a name="l00174"></a>00174 
 
202
<a name="l00175"></a>00175     <a class="code" href="a00107.html#adb34fb3c04bbc949324b069298b6ad60">CreateSets</a>();
 
203
<a name="l00176"></a>00176     <a class="code" href="a00107.html#a8b36b27c3c40d9e559c078673a3a4dc9">FillSets</a>();
 
204
<a name="l00177"></a>00177     <a class="code" href="a00107.html#a5cb27a7766b9e7c1ea79b2741714b404">EnumerateSets</a>();
 
205
<a name="l00178"></a>00178     <a class="code" href="a00107.html#a1bdd608971ec7ea3d5c76cf21c7d92e7">OrSets</a>();
 
206
<a name="l00179"></a>00179 
 
207
<a name="l00180"></a>00180     time_t end_time = time(0);
 
208
<a name="l00181"></a>00181     <span class="keywordtype">unsigned</span> elapsed = unsigned(end_time - start_time);
 
209
<a name="l00182"></a>00182     cout &lt;&lt; <span class="stringliteral">&quot;elapsed=&quot;</span> &lt;&lt; elapsed &lt;&lt; endl;
 
210
<a name="l00183"></a>00183     <span class="keywordtype">unsigned</span> ops;
 
211
<a name="l00184"></a>00184     <span class="keywordflow">if</span> (elapsed)
 
212
<a name="l00185"></a>00185         ops = <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a> / elapsed;
 
213
<a name="l00186"></a>00186     <span class="keywordflow">else</span>
 
214
<a name="l00187"></a>00187         ops = <a class="code" href="a00107.html#a2508b4033cfced61642ad9358d67dd2a">setscount</a>;
 
215
<a name="l00188"></a>00188 
 
216
<a name="l00189"></a>00189     cout &lt;&lt; <span class="stringliteral">&quot;Time = &quot;</span> &lt;&lt; (end_time - start_time) &lt;&lt; endl;
 
217
<a name="l00190"></a>00190     cout &lt;&lt; <span class="stringliteral">&quot;Operations per second:&quot;</span> &lt;&lt; ops &lt;&lt; endl;
 
218
<a name="l00191"></a>00191 
 
219
<a name="l00192"></a>00192     <a class="code" href="a00107.html#aa777f579687be6096cdbb8b2d70baf6e">DestroySets</a>();
 
220
<a name="l00193"></a>00193 
 
221
<a name="l00194"></a>00194     <span class="keywordflow">return</span> 0;
 
222
<a name="l00195"></a>00195 }
 
223
<a name="l00196"></a>00196 
 
224
<a name="l00197"></a>00197   
 
225
</pre></div></div>
 
226
<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Nov 22 10:49:36 2009 for BitMagic by&nbsp;
 
227
<a href="http://www.doxygen.org/index.html">
 
228
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
 
229
</body>
 
230
</html>