Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72595 - in sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html: . style
From: cpp.cabrera_at_[hidden]
Date: 2011-06-14 17:20:21


Author: alejandro
Date: 2011-06-14 17:20:20 EDT (Tue, 14 Jun 2011)
New Revision: 72595
URL: http://svn.boost.org/trac/boost/changeset/72595

Log:
Added example output to tutorial, updated tutorial to match existing examples.
Text files modified:
   sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/style/my.css | 10 ++++++++++
   sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/tutorial.html | 33 +++++++++++++++++++++++----------
   2 files changed, 33 insertions(+), 10 deletions(-)

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/style/my.css
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/style/my.css (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/style/my.css 2011-06-14 17:20:20 EDT (Tue, 14 Jun 2011)
@@ -46,6 +46,16 @@
     margin-right: 5%;
 }
 
+.example_output {
+ white-space: pre;
+ background: #000000;
+ font-family: monospace;
+ display: block;
+ margin-left: 5%;
+ margin-right: 5%;
+ color: silver;
+};
+
 .c_comment {
     color: maroon;
 }

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/tutorial.html
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/tutorial.html (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/doc/html/tutorial.html 2011-06-14 17:20:20 EDT (Tue, 14 Jun 2011)
@@ -71,7 +71,7 @@
       <code class="c_type">int</code> <code class="c_func">main</code>() {
         <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">INSERT_MAX</code> = 5000;
         <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">CONTAINS_MAX</code> = 10000;
- <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">NUM_BITS</code> = 512;
+ <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">NUM_BITS</code> = 8192;
 
         <code class="c_type">bloom_filter</code>&lt;int, NUM_BITS&gt; <code class="c_id">bloom</code>;
         <code class="c_type">size_t</code><code class="c_id"> collisions</code> = 0;
@@ -91,10 +91,14 @@
         <code class="c_keyword">return</code> 0;
       }
     </div>
+ <div class="example_output">
+ $> ./basic_bloom
+ collisions: 1808
+ </div>
 
     <p>
       Above, we see a simple example that instantiates the default Bloom filter, inserts integers
- 0 - 4999, and then queries the existence of those integers. That's all it takes to use
+ 0 - 4999, and then queries the existence of those integers. That's all it takes to use
       this Bloom filter!
     </p>
     <p>
@@ -147,19 +151,21 @@
       <code class="c_keyword">using namespace</code> <code class="c_namespace">std</code>;
         
       <code class="c_type">int</code> <code class="c_func">main</code>() {
- <code class="c_keyword">typedef</code> <code class="c_namespace">boost::mpl::vector</code>&lt;<code class="c_type">boost_hash</code>&lt;<code class="c_id">int, 1</code>&gt;,
- <code class="c_type">boost_hash</code>&lt;<code class="c_id">int, 2</code>&gt;,
- <code class="c_type">boost_hash</code>&lt;<code class="c_id">int, 3</code>&gt; &gt; <code class="c_type">HashFns</code>;
+ <code class="c_keyword">typedef</code> <code class="c_namespace">boost::mpl::vector</code>&lt;<code class="c_type">boost_hash</code>&lt;<code class="c_id">int, 0</code>&gt; &gt; <code class="c_type">HashFns</code>;
 
         <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">INSERT_MAX</code> = 5000;
         <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">CONTAINS_MAX</code> = 10000;
- <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">NUM_BITS</code> = 1024;
+ <code class="c_keyword">static const</code> <code class="c_type">size_t</code> <code class="c_id">NUM_BITS</code> = 8192;
 
         <code class="c_type">bloom_filter</code>&lt;int, NUM_BITS, HashFns&gt; <code class="c_id">bloom</code>;
         <code class="c_type">size_t</code><code class="c_id"> collisions</code> = 0;
 
+ cout &lt;&lt; <code class="c_str">"bloom filter storage size: "</code>
+ &lt;&lt; sizeof(bloom) &lt;&lt; <code class="c_str">" bytes"</code>
+ &lt;&lt; endl;
+
         cout &lt;&lt; <code class="c_str">"false positive rate: "</code>
- &lt;&lt; bloom.false_positive_rate()
+ &lt;&lt; bloom.false_positive_rate() * 100.0 &lt;&lt; <code class="c_str">"%"</code>
              &lt;&lt; endl;
 
         <code class="c_keyword">for</code> (<code class="c_type">int</code><code class="c_id"> i</code> = 0; i &lt; INSERT_MAX; ++i) {
@@ -171,16 +177,23 @@
         }
 
         cout &lt;&lt; <code class="c_str">"false positive rate: "</code>
- &lt;&lt; bloom.false_positive_rate()
+ &lt;&lt; bloom.false_positive_rate() * 100.0 &lt;&lt; <code class="c_str">"%"</code>
              &lt;&lt; endl;
 
- cout &lt;&lt; <code class="c_str">"collisions: "</code>
+ cout &lt;&lt; <code class="c_str">"collisions (false positives): "</code>
              &lt;&lt; collisions
              &lt;&lt; endl;
 
         <code class="c_keyword">return</code> 0;
       }
     </div>
+ <div class="example_output">
+ $> ./advanced_bloom
+ bloom filter storage size: 1024 bytes
+ false positive rate before inserts: 0%
+ false positive rate after inserts: 45.684%
+ collisions (false positives): 1808
+ </div>
 
     <p>
       All the details of insertion and querying the Bloom filter are handled
@@ -205,7 +218,7 @@
 
     <footer>
       <p>
- Last revised: <time datetime="2011-06-08">June 8, 2011</time>.
+ Last revised: <time datetime="2011-06-14">June 14, 2011</time>.
       </p>
 
       <p class="copyright">


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk