|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72592 - sandbox/bloom_filter/trunk/libs/bloom_filter/example
From: cpp.cabrera_at_[hidden]
Date: 2011-06-14 17:19:49
Author: alejandro
Date: 2011-06-14 17:19:48 EDT (Tue, 14 Jun 2011)
New Revision: 72592
URL: http://svn.boost.org/trac/boost/changeset/72592
Log:
Updated example programs to make them more interesting and to better illustrate the properties of the default Bloom filter.
Removed:
sandbox/bloom_filter/trunk/libs/bloom_filter/example/PLACE_HOLDER
Text files modified:
sandbox/bloom_filter/trunk/libs/bloom_filter/example/advanced_bloom.cpp | 14 ++++++--------
sandbox/bloom_filter/trunk/libs/bloom_filter/example/basic_bloom.cpp | 6 +++---
2 files changed, 9 insertions(+), 11 deletions(-)
Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/example/PLACE_HOLDER
==============================================================================
Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/example/advanced_bloom.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/example/advanced_bloom.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/example/advanced_bloom.cpp 2011-06-14 17:19:48 EDT (Tue, 14 Jun 2011)
@@ -17,31 +17,29 @@
using namespace std;
int main () {
- typedef boost::mpl::vector<boost_hash<int, 1>,
- boost_hash<int, 2>,
- boost_hash<int, 3> > HashFns;
+ typedef boost::mpl::vector<boost_hash<int, 0> > HashFns;
static const size_t INSERT_MAX = 5000;
static const size_t CONTAINS_MAX = 10000;
- static const size_t NUM_BITS = 1024;
+ static const size_t NUM_BITS = 8192;
bloom_filter<int, NUM_BITS, HashFns> bloom;
size_t collisions = 0;
cout << "false positive rate: "
- << bloom.false_positive_rate()
+ << bloom.false_positive_rate() * 100.0 << "%"
<< endl;
- for (int i = 0; i < INSERT_MAX; ++i) {
+ for (size_t i = 0; i < INSERT_MAX; ++i) {
bloom.insert(i);
}
- for (int i = INSERT_MAX; i < CONTAINS_MAX_MAX; ++i) {
+ for (size_t i = INSERT_MAX; i < CONTAINS_MAX; ++i) {
if (bloom.contains(i)) ++collisions;
}
cout << "false positive rate: "
- << bloom.false_positive_rate()
+ << bloom.false_positive_rate() * 100.0 << "%"
<< endl;
cout << "collisions: " << collisions << endl;
Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/example/basic_bloom.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/example/basic_bloom.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/example/basic_bloom.cpp 2011-06-14 17:19:48 EDT (Tue, 14 Jun 2011)
@@ -19,16 +19,16 @@
int main () {
static const size_t INSERT_MAX = 5000;
static const size_t CONTAINS_MAX = 10000;
- static const size_t NUM_BITS = 512;
+ static const size_t NUM_BITS = 8192;
bloom_filter<int, NUM_BITS> bloom;
size_t collisions = 0;
- for (int i = 0; i < INSERT_MAX; ++i) {
+ for (size_t i = 0; i < INSERT_MAX; ++i) {
bloom.insert(i);
}
- for (int i = INSERT_MAX; i < CONTAINS_MAX_MAX; ++i) {
+ for (size_t i = INSERT_MAX; i < CONTAINS_MAX; ++i) {
if (bloom.contains(i)) ++collisions;
}
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