~ubuntu-branches/ubuntu/intrepid/bmagic/intrepid

« back to all changes in this revision

Viewing changes to html/a00112.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: sample2.cpp Source File</title>
 
3
<title>BitMagic: bmalgo.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_000003.html">sample2</a></div>
10
 
<h1>sample2.cpp</h1><a href="a00084.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 sample2.cpp</span>
34
 
00025 <span class="comment">  Example demonstrates using set operations AND, OR, XOR, etc.</span>
35
 
00026 <span class="comment">  For more information please visit:  http://bmagic.sourceforge.net</span>
36
 
00027 <span class="comment"> </span>
37
 
00028 <span class="comment">*/</span>
38
 
00029 
39
 
00030 
40
 
00031 <span class="preprocessor">#include &lt;iostream&gt;</span>
41
 
00032 <span class="preprocessor">#include "<a class="code" href="a00074.html">bm.h</a>"</span>
42
 
00033 
43
 
00034 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
44
 
00035 
45
 
<a name="l00036"></a><a class="code" href="a00084.html#a0">00036</a> <span class="keywordtype">void</span> <a class="code" href="a00084.html#a0">print_bvector</a>(<span class="keyword">const</span> <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>&amp; bv)
46
 
00037 {
47
 
00038     <span class="keywordtype">unsigned</span> value = bv.get_first();
48
 
00039     <span class="keywordflow">do</span>
49
 
00040     {
50
 
00041         cout &lt;&lt; value;
51
 
00042         value = bv.get_next(value);
52
 
00043         <span class="keywordflow">if</span> (value)
53
 
00044         {
54
 
00045             cout &lt;&lt; <span class="stringliteral">","</span>;
55
 
00046         }
56
 
00047         <span class="keywordflow">else</span>
57
 
00048         {
58
 
00049             <span class="keywordflow">break</span>;
59
 
00050         }
60
 
00051     } <span class="keywordflow">while</span>(1);
61
 
00052     cout &lt;&lt; endl;
62
 
00053 }
63
 
00054 
64
 
<a name="l00055"></a><a class="code" href="a00084.html#a1">00055</a> <span class="keywordtype">int</span> <a class="code" href="a00083.html#a0">main</a>(<span class="keywordtype">void</span>)
65
 
00056 {
66
 
00057     <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>   bv1;    
67
 
00058     <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>   bv2;
68
 
00059     <a class="code" href="a00048.html">bm::bvector&lt;&gt;</a>   bv3;
69
 
00060 
70
 
00061     bv1.<a class="code" href="a00048.html#a19">set</a>(10);
71
 
00062     bv1.<a class="code" href="a00048.html#a19">set</a>(100);
72
 
00063     bv1.<a class="code" href="a00048.html#a19">set</a>(1000000);
73
 
00064 
74
 
00065 
75
 
00066     bv2.<a class="code" href="a00048.html#a19">set</a>(10);
76
 
00067     bv2.<a class="code" href="a00048.html#a19">set</a>(100);
77
 
00068 
78
 
00069     <span class="comment">// Logical AND operation on bv2 (bv1 is the argument)</span>
79
 
00070     <span class="comment">// bv2 = bv2 AND bv1</span>
80
 
00071 
81
 
00072     bv3 = bv1 &amp; bv2;
82
 
00073     <a class="code" href="a00084.html#a0">print_bvector</a>(bv3);
83
 
00074 
84
 
00075     bv2 &amp;= bv1;  <span class="comment">// You also can use: bv2.bit_and(bv1);</span>
85
 
00076     <a class="code" href="a00084.html#a0">print_bvector</a>(bv2);
86
 
00077     
87
 
00078     <span class="comment">// bv2 = bv2 OR bv1</span>
88
 
00079 
89
 
00080     bv3 = bv1 | bv2;
90
 
00081     <a class="code" href="a00084.html#a0">print_bvector</a>(bv3);
91
 
00082 
92
 
00083     bv2 |= bv1;  <span class="comment">//  You can also use: bv2.bit_or(bv1);</span>
93
 
00084     <a class="code" href="a00084.html#a0">print_bvector</a>(bv2);
94
 
00085 
95
 
00086     
96
 
00087     bv1.<a class="code" href="a00048.html#a19">set</a>(1000000, <span class="keyword">false</span>);
97
 
00088     
98
 
00089     <span class="comment">// bv2 = bv2 SUB bv1</span>
99
 
00090 
100
 
00091     bv3 = bv2 - bv1;
101
 
00092     <a class="code" href="a00084.html#a0">print_bvector</a>(bv3);
102
 
00093 
103
 
00094     bv2 -= bv1;   <span class="comment">// You can also use: bv2.bit_sub(bv1);</span>
104
 
00095     <a class="code" href="a00084.html#a0">print_bvector</a>(bv2);
105
 
00096 
106
 
00097     <span class="comment">// bv2 XOR bv1</span>
107
 
00098 
108
 
00099     bv3 = bv2 ^ bv1;
109
 
00100     <a class="code" href="a00084.html#a0">print_bvector</a>(bv3);
110
 
00101 
111
 
00102     bv2 ^= bv1;  <span class="comment">// You can also use: bv2.bit_xor(bv1);</span>
112
 
00103     <a class="code" href="a00084.html#a0">print_bvector</a>(bv2);
113
 
00104 
114
 
00105     <span class="comment">// For lexicographical comparison there is set of overloaded</span>
115
 
00106     <span class="comment">// operators and function compare.</span>
116
 
00107 
117
 
00108     <span class="keywordflow">if</span> (bv2 == bv3)
118
 
00109     {
119
 
00110         cerr &lt;&lt; <span class="stringliteral">"Equivalent. Comparison result = "</span> 
120
 
00111              &lt;&lt; bv2.<a class="code" href="a00048.html#a56">compare</a>(bv3) &lt;&lt; endl;
121
 
00112     }
122
 
00113     <span class="keywordflow">else</span>
123
 
00114     {
124
 
00115         cout &lt;&lt; <span class="stringliteral">"Error."</span> &lt;&lt; endl;
125
 
00116         <span class="keywordflow">return</span> 1;
126
 
00117     }
127
 
00118 
128
 
00119 
129
 
00120     <span class="keywordflow">return</span> 0;
130
 
00121 }
131
 
</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>bmalgo.h File Reference</h1><code>#include "<a class="el" href="a00137.html">bm.h</a>"</code><br>
 
11
<code>#include "<a class="el" href="a00141.html">bmfunc.h</a>"</code><br>
 
12
<code>#include "<a class="el" href="a00140.html">bmdef.h</a>"</code><br>
 
13
<code>#include "bmalgo_impl.h"</code><br>
 
14
<code>#include "<a class="el" href="a00143.html">bmundef.h</a>"</code><br>
 
15
 
 
16
<p>
 
17
Include dependency graph for bmalgo.h:<p><center><img src="a00167.png" border="0" usemap="#bmalgo.h_map" alt=""></center>
 
18
<map name="bmalgo.h_map">
 
19
<area href="a00111.html" shape="rect" coords="157,328,197,349" alt="">
 
20
<area href="a00114.html" shape="rect" coords="284,5,340,27" alt="">
 
21
<area href="a00115.html" shape="rect" coords="280,555,344,576" alt="">
 
22
<area href="a00117.html" shape="rect" coords="276,600,348,621" alt="">
 
23
<area href="a00113.html" shape="rect" coords="277,96,347,117" alt="">
 
24
<area href="a00116.html" shape="rect" coords="280,192,344,213" alt="">
 
25
<area href="a00118.html" shape="rect" coords="279,328,345,349" alt="">
 
26
<area href="a00119.html" shape="rect" coords="276,237,348,259" alt="">
 
27
</map>
 
28
 
 
29
<p>
 
30
This graph shows which files directly or indirectly include this file:<p><center><img src="a00168.png" border="0" usemap="#bmalgo.hdep_map" alt=""></center>
 
31
<map name="bmalgo.hdep_map">
 
32
<area href="a00128.html" shape="rect" coords="129,5,217,26" alt="">
 
33
</map>
 
34
 
 
35
<p>
 
36
<a href="a00138.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
 
37
<tr><td></td></tr>
 
38
</table>
 
39
<hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:28 2007 for BitMagic by&nbsp;
132
40
<a href="http://www.doxygen.org/index.html">
133
41
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>
134
42
</body>