~ubuntu-branches/ubuntu/vivid/bmagic/vivid

« back to all changes in this revision

Viewing changes to html/a00118.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: sample8.cpp Source File</title>
 
3
<title>BitMagic: bmvmin.h File Reference</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
8
<div class="nav">
9
 
<a class="el" href="dir_000001.html">samples</a>&nbsp;/&nbsp;<a class="el" href="dir_000009.html">sample8</a></div>
10
 
<h1>sample8.cpp</h1><a href="a00090.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
11
 
00002 <span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
12
 
00003 <span class="comment"></span>
13
 
00004 <span class="comment">Permission is hereby granted, free of charge, to any person </span>
14
 
00005 <span class="comment">obtaining a copy of this software and associated documentation </span>
15
 
00006 <span class="comment">files (the "Software"), to deal in the Software without restriction, </span>
16
 
00007 <span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
17
 
00008 <span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
18
 
00009 <span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
19
 
00010 <span class="comment">subject to the following conditions:</span>
20
 
00011 <span class="comment"></span>
21
 
00012 <span class="comment">The above copyright notice and this permission notice shall be included </span>
22
 
00013 <span class="comment">in all copies or substantial portions of the Software.</span>
23
 
00014 <span class="comment"></span>
24
 
00015 <span class="comment">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, </span>
25
 
00016 <span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
26
 
00017 <span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
27
 
00018 <span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
28
 
00019 <span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
29
 
00020 <span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
30
 
00021 <span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
31
 
00022 <span class="comment">*/</span>
32
 
00023 <span class="comment"></span>
33
 
00024 <span class="comment">/** \example sample8.cpp</span>
34
 
00025 <span class="comment"></span>
35
 
00026 <span class="comment">    Example demonstrates some STL compatability set operations using</span>
36
 
00027 <span class="comment">    set iterators.</span>
37
 
00028 <span class="comment"> </span>
38
 
00029 <span class="comment">  \sa bm::bvector&lt;&gt;::enumerator </span>
39
 
00030 <span class="comment">  \sa bm::bvector&lt;&gt;::insert_iterator</span>
40
 
00031 <span class="comment"></span>
41
 
00032 <span class="comment">   For more information please visit:  http://bmagic.sourceforge.net</span>
42
 
00033 <span class="comment"></span>
43
 
00034 <span class="comment">*/</span>
44
 
00035 
45
 
00036 <span class="preprocessor">#include &lt;iostream&gt;</span>
46
 
00037 <span class="preprocessor">#include &lt;algorithm&gt;</span>
47
 
00038 <span class="preprocessor">#include &lt;vector&gt;</span>
48
 
00039 <span class="preprocessor">#include &lt;list&gt;</span>
49
 
00040 
50
 
00041 <span class="keyword">using</span> std::vector;
51
 
00042 <span class="keyword">using</span> std::list;
52
 
00043 
53
 
00044 <span class="comment">// This example requires STL compatibility</span>
54
 
00045 <span class="preprocessor">#ifdef BM_NO_STL</span>
55
 
00046 <span class="preprocessor"></span><span class="preprocessor"># undef BM_NO_STL</span>
56
 
00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
57
 
00048 <span class="preprocessor"></span>
58
 
00049 <span class="preprocessor">#include "<a class="code" href="a00074.html">bm.h</a>"</span>
59
 
00050 
60
 
00051 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
61
 
00052 
62
 
<a name="l00053"></a><a class="code" href="a00090.html#a0">00053</a> <span class="keywordtype">void</span> <a class="code" href="a00087.html#a0">Print</a>(<span class="keywordtype">unsigned</span> n)
63
 
00054 {
64
 
00055     cout &lt;&lt; n &lt;&lt; endl;;
65
 
00056 }
66
 
00057 
67
 
00058 <span class="comment">// Utility template function used to print container</span>
68
 
<a name="l00059"></a><a class="code" href="a00090.html#a1">00059</a> <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; <span class="keywordtype">void</span> <a class="code" href="a00090.html#a1">PrintContainer</a>(T first, T last)
69
 
00060 {
70
 
00061     <span class="keywordflow">if</span> (first == last)
71
 
00062         cout &lt;&lt; <span class="stringliteral">"&lt;EMPTY SET&gt;"</span>;
72
 
00063     <span class="keywordflow">else</span>
73
 
00064         <span class="keywordflow">for</span>(;first != last; ++first)
74
 
00065             cout &lt;&lt; *first &lt;&lt; <span class="stringliteral">";"</span>;
75
 
00066     cout &lt;&lt; endl;
76
 
00067 }
77
 
00068 
78
 
<a name="l00069"></a><a class="code" href="a00090.html#a2">00069</a> <span class="keywordtype">int</span> <a class="code" href="a00083.html#a0">main</a>(<span class="keywordtype">void</span>)
79
 
00070 {
80
 
00071     <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>   bv;    
81
 
00072 
82
 
00073     bv[10] = <span class="keyword">true</span>;
83
 
00074     bv[100] = <span class="keyword">true</span>;
84
 
00075     bv[10000] = <span class="keyword">true</span>;
85
 
00076     
86
 
00077     cout &lt;&lt; <span class="stringliteral">"Source set:"</span>;
87
 
00078     <a class="code" href="a00090.html#a1">PrintContainer</a>(bv.<a class="code" href="a00048.html#a59">first</a>(), bv.<a class="code" href="a00048.html#a60">end</a>());
88
 
00079     
89
 
00080     <span class="comment">// copy all bitset information into STL vector using copy algorithm</span>
90
 
00081     {
91
 
00082         vector&lt;unsigned&gt; vect;
92
 
00083         vect.<a class="code" href="a00048.html#a29">resize</a>(bv.<a class="code" href="a00048.html#a26">count</a>());
93
 
00084         std::copy(bv.<a class="code" href="a00048.html#a59">first</a>(), bv.<a class="code" href="a00048.html#a60">end</a>(), vect.begin());
94
 
00085         cout &lt;&lt; <span class="stringliteral">"Vector:"</span>;
95
 
00086         <a class="code" href="a00090.html#a1">PrintContainer</a>(vect.begin(), vect.end());
96
 
00087     }
97
 
00088 
98
 
00089     <span class="comment">// doing the same with the help of back_inserter</span>
99
 
00090 
100
 
00091     {
101
 
00092         list&lt;unsigned&gt; lst;
102
 
00093         std::copy(bv.<a class="code" href="a00048.html#a59">first</a>(), bv.<a class="code" href="a00048.html#a60">end</a>(), std::back_inserter(lst));
103
 
00094         cout &lt;&lt; <span class="stringliteral">"List:"</span>;
104
 
00095         <a class="code" href="a00090.html#a1">PrintContainer</a>(lst.begin(), lst.end());
105
 
00096     }
106
 
00097 
107
 
00098     {
108
 
00099         vector&lt;unsigned&gt;   vect;
109
 
00100         vector&lt;unsigned&gt;   res1, res2, res3;
110
 
00101         
111
 
00102         vect.push_back(100);
112
 
00103         vect.push_back(15);
113
 
00104         vect.push_back(150);
114
 
00105         
115
 
00106         cout &lt;&lt; <span class="stringliteral">"Argument vector for set operations:"</span>;
116
 
00107         <a class="code" href="a00090.html#a1">PrintContainer</a>(vect.begin(), vect.end());
117
 
00108         
118
 
00109         <span class="comment">// set should be ordered by &lt; to make set algorithms possible</span>
119
 
00110         std::sort(vect.begin(), vect.end());
120
 
00111         cout &lt;&lt; endl;
121
 
00112         
122
 
00113         std::set_union(bv.<a class="code" href="a00048.html#a59">first</a>(), bv.<a class="code" href="a00048.html#a60">end</a>(),
123
 
00114                        vect.begin(), vect.<a class="code" href="a00048.html#a60">end</a>(),
124
 
00115                        std::back_inserter(res1)); <span class="comment">//10;15;100;150;10000</span>
125
 
00116         cout &lt;&lt; <span class="stringliteral">"Set union:"</span> &lt;&lt; endl;
126
 
00117         <a class="code" href="a00090.html#a1">PrintContainer</a>(res1.begin(), res1.end());
127
 
00118         
128
 
00119         std::set_intersection(bv.<a class="code" href="a00048.html#a59">first</a>(), bv.<a class="code" href="a00048.html#a60">end</a>(),
129
 
00120                               vect.begin(), vect.<a class="code" href="a00048.html#a60">end</a>(),
130
 
00121                               std::back_inserter(res2));  <span class="comment">// 100</span>
131
 
00122         cout &lt;&lt; <span class="stringliteral">"Set intersection:"</span> &lt;&lt; endl;
132
 
00123         <a class="code" href="a00090.html#a1">PrintContainer</a>(res2.begin(), res2.end());
133
 
00124 
134
 
00125         vector&lt;unsigned&gt;::const_iterator it1 = vect.begin();
135
 
00126         vector&lt;unsigned&gt;::const_iterator it2 = vect.<a class="code" href="a00048.html#a60">end</a>();
136
 
00127         <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>::enumerator en = bv.<a class="code" href="a00048.html#a59">first</a>();
137
 
00128         <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>::enumerator en2= bv.<a class="code" href="a00048.html#a60">end</a>();
138
 
00129         
139
 
00130         std::set_difference(en, en2,
140
 
00131                             it1, it2,
141
 
00132                             std::back_inserter(res3));  <span class="comment">// 10;10000</span>
142
 
00133 
143
 
00134         cout &lt;&lt; <span class="stringliteral">"Set diff:"</span> &lt;&lt; endl;
144
 
00135         <a class="code" href="a00090.html#a1">PrintContainer</a>(res3.begin(), res3.end());
145
 
00136         
146
 
00137     }
147
 
00138 
148
 
00139     <span class="comment">// Using bvector&lt;&gt;::insert_iterator to set bits</span>
149
 
00140     {
150
 
00141         <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a> bv1;
151
 
00142         std::vector&lt;unsigned&gt; vect;
152
 
00143         
153
 
00144         vect.push_back(300);
154
 
00145         vect.push_back(200);
155
 
00146         vect.push_back(275);
156
 
00147         vect.push_back(200);
157
 
00148         
158
 
00149         cout &lt;&lt; endl &lt;&lt; <span class="stringliteral">"Source vector:"</span>;
159
 
00150         <a class="code" href="a00090.html#a1">PrintContainer</a>(vect.begin(), vect.end()); <span class="comment">// 300;200;275;200;</span>
160
 
00151         
161
 
00152         <span class="comment">// The "side effect" of this operation is that we sorted</span>
162
 
00153         <span class="comment">// the input sequence and eliminated duplicates</span>
163
 
00154         
164
 
00155         std::copy(vect.begin(), vect.end(), bv1.<a class="code" href="a00048.html#a22">inserter</a>());
165
 
00156         cout &lt;&lt; <span class="stringliteral">"Bitset:"</span>;
166
 
00157         
167
 
00158         <a class="code" href="a00090.html#a1">PrintContainer</a>(bv1.<a class="code" href="a00048.html#a59">first</a>(), bv1.<a class="code" href="a00048.html#a60">end</a>());  <span class="comment">// 200;275;300</span>
168
 
00159     }
169
 
00160     
170
 
00161     
171
 
00162     <span class="keywordflow">return</span> 0;
172
 
00163 }
173
 
00164 
174
 
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Apr 20 13:28:46 2006 for BitMagic by&nbsp;
 
9
<a class="el" href="dir_000000.html">src</a></div>
 
10
<h1>bmvmin.h File Reference</h1>
 
11
<p>
 
12
This graph shows which files directly or indirectly include this file:<p><center><img src="a00177.png" border="0" usemap="#bmvmin.hdep_map" alt=""></center>
 
13
<map name="bmvmin.hdep_map">
 
14
<area href="a00111.html" shape="rect" coords="132,215,172,236" alt="">
 
15
<area href="a00112.html" shape="rect" coords="232,6,296,27" alt="">
 
16
<area href="a00128.html" shape="rect" coords="356,30,444,51" alt="">
 
17
<area href="a00120.html" shape="rect" coords="221,102,307,123" alt="">
 
18
<area href="a00121.html" shape="rect" coords="221,147,307,168" alt="">
 
19
<area href="a00122.html" shape="rect" coords="220,192,308,214" alt="">
 
20
<area href="a00123.html" shape="rect" coords="221,238,307,259" alt="">
 
21
<area href="a00124.html" shape="rect" coords="220,283,308,304" alt="">
 
22
<area href="a00125.html" shape="rect" coords="221,328,307,350" alt="">
 
23
<area href="a00126.html" shape="rect" coords="221,374,307,395" alt="">
 
24
<area href="a00127.html" shape="rect" coords="220,419,308,440" alt="">
 
25
</map>
 
26
 
 
27
<p>
 
28
<a href="a00144.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
 
29
<tr><td></td></tr>
 
30
<tr><td colspan="2"><br><h2>Namespaces</h2></td></tr>
 
31
<tr><td class="memItemLeft" nowrap align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00129.html">bm</a></td></tr>
 
32
 
 
33
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
 
34
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00118.html#a0">BM_MINISET_GAPLEN</a>&nbsp;&nbsp;&nbsp;(<a class="el" href="a00104.html">bm::gap_len_table</a>&lt;true&gt;::_len[0])</td></tr>
 
35
 
 
36
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00118.html#a1">BM_MINISET_ARRSIZE</a>(x)&nbsp;&nbsp;&nbsp;((x / 32) + ( (x % 32) &amp;&amp; 1 ))</td></tr>
 
37
 
 
38
</table>
 
39
<hr><h2>Define Documentation</h2>
 
40
<a class="anchor" name="a1" doxytag="bmvmin.h::BM_MINISET_ARRSIZE"></a><p>
 
41
<table class="mdTable" cellpadding="2" cellspacing="0">
 
42
  <tr>
 
43
    <td class="mdRow">
 
44
      <table cellpadding="0" cellspacing="0" border="0">
 
45
        <tr>
 
46
          <td class="md" nowrap valign="top">#define BM_MINISET_ARRSIZE          </td>
 
47
          <td class="md" valign="top">(&nbsp;</td>
 
48
          <td class="md" nowrap valign="top">x&nbsp;</td>
 
49
          <td class="mdname1" valign="top" nowrap>          </td>
 
50
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
 
51
          <td class="md" nowrap>&nbsp;&nbsp;&nbsp;((x / 32) + ( (x % 32) &amp;&amp; 1 ))</td>
 
52
        </tr>
 
53
      </table>
 
54
    </td>
 
55
  </tr>
 
56
</table>
 
57
<table cellspacing="5" cellpadding="0" border="0">
 
58
  <tr>
 
59
    <td>
 
60
      &nbsp;
 
61
    </td>
 
62
    <td>
 
63
 
 
64
<p>
 
65
 
 
66
<p>
 
67
Definition at line <a class="el" href="a00144.html#l00035">35</a> of file <a class="el" href="a00144.html">bmvmin.h</a>.
 
68
<p>
 
69
Referenced by <a class="el" href="a00144.html#l00136">bm::miniset&lt; A, N &gt;::mem_used()</a>, <a class="el" href="a00144.html#l00251">bm::bvmini&lt; N &gt;::swap()</a>, and <a class="el" href="a00144.html#l00079">bm::miniset&lt; A, N &gt;::~miniset()</a>.    </td>
 
70
  </tr>
 
71
</table>
 
72
<a class="anchor" name="a0" doxytag="bmvmin.h::BM_MINISET_GAPLEN"></a><p>
 
73
<table class="mdTable" cellpadding="2" cellspacing="0">
 
74
  <tr>
 
75
    <td class="mdRow">
 
76
      <table cellpadding="0" cellspacing="0" border="0">
 
77
        <tr>
 
78
          <td class="md" nowrap valign="top">#define BM_MINISET_GAPLEN&nbsp;&nbsp;&nbsp;(<a class="el" href="a00104.html">bm::gap_len_table</a>&lt;true&gt;::_len[0])          </td>
 
79
        </tr>
 
80
      </table>
 
81
    </td>
 
82
  </tr>
 
83
</table>
 
84
<table cellspacing="5" cellpadding="0" border="0">
 
85
  <tr>
 
86
    <td>
 
87
      &nbsp;
 
88
    </td>
 
89
    <td>
 
90
 
 
91
<p>
 
92
 
 
93
<p>
 
94
Definition at line <a class="el" href="a00144.html#l00034">34</a> of file <a class="el" href="a00144.html">bmvmin.h</a>.
 
95
<p>
 
96
Referenced by <a class="el" href="a00144.html#l00136">bm::miniset&lt; A, N &gt;::mem_used()</a>, <a class="el" href="a00144.html#l00102">bm::miniset&lt; A, N &gt;::set()</a>, and <a class="el" href="a00144.html#l00079">bm::miniset&lt; A, N &gt;::~miniset()</a>.    </td>
 
97
  </tr>
 
98
</table>
 
99
<hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:30 2007 for BitMagic by&nbsp;
175
100
<a href="http://www.doxygen.org/index.html">
176
101
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>
177
102
</body>