Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53781 - in sandbox/bloom_filter/trunk: boost boost/bloom_filter libs/bloom_filter/test
From: mikhailberis_at_[hidden]
Date: 2009-06-10 00:40:27


Author: mikhailberis
Date: 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
New Revision: 53781
URL: http://svn.boost.org/trac/boost/changeset/53781

Log:
Renaming current implementation to static_bloom_filter to give way to construct-time sized "dynamic" bloom filter.
Added:
   sandbox/bloom_filter/trunk/boost/bloom_filter/static_bloom_filter.hpp
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_construct_from_bitset_test.cpp (contents, props changed)
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_default_construct_test.cpp (contents, props changed)
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_equality_test.cpp (contents, props changed)
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_swap_adl_test.cpp (contents, props changed)
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_test.cpp
      - copied, changed from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp
Removed:
   sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp
Text files modified:
   sandbox/bloom_filter/trunk/boost/bloom_filter.hpp | 2 +-
   sandbox/bloom_filter/trunk/boost/bloom_filter/static_bloom_filter.hpp | 22 +++++++++++-----------
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 | 10 +++++-----
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_construct_from_bitset_test.cpp | 6 +++---
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_default_construct_test.cpp | 6 +++---
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_equality_test.cpp | 4 ++--
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_swap_adl_test.cpp | 4 ++--
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_test.cpp | 4 ++--
   8 files changed, 29 insertions(+), 29 deletions(-)

Modified: sandbox/bloom_filter/trunk/boost/bloom_filter.hpp
==============================================================================
--- sandbox/bloom_filter/trunk/boost/bloom_filter.hpp (original)
+++ sandbox/bloom_filter/trunk/boost/bloom_filter.hpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -6,7 +6,7 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/bloom_filter/bloom_filter.hpp>
+#include <boost/bloom_filter/static_bloom_filter.hpp>
 
 #endif
 

Deleted: sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp
==============================================================================
--- sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,107 +0,0 @@
-#ifndef BLOOM_FILTER_20090608_0
-#define BLOOM_FILTER_20090608_0
-
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <bitset>
-#include <boost/array.hpp>
-#include <boost/function.hpp>
-
-#include <boost/type_traits/add_const.hpp>
-#include <boost/type_traits/add_reference.hpp>
-#include <boost/bloom_filter/detail/default_hash.hpp>
-
-namespace boost {
-
- template <class Input, size_t M, size_t K>
- struct bloom_filter {
- public:
- typedef std::bitset<M> bitset_type;
-
- private:
- bitset_type bit_set;
- array<function<size_t(Input)>, K> hash_array;
-
- typedef typename add_reference<typename add_const<Input>::type>::type const_ref;
-
- public:
- static size_t const size = M;
- static size_t const functions = K;
- typedef Input element_type;
-
- explicit bloom_filter(
- array<function<size_t(Input)>, K> const & hash_functions
- ) :
- hash_array(hash_functions) {}
-
- bloom_filter(bitset_type const & initial_state = bitset_type())
- : bit_set(initial_state)
- {
- for(size_t k = 0; k < K; ++k)
- hash_array[k] = detail::default_hash<Input,M>(k);
- }
-
- bloom_filter(bloom_filter const & other) :
- bit_set(other.bit_set), hash_array(other.hash_array) {}
-
- bloom_filter & operator=(bloom_filter rhs) {
- rhs.swap(*this);
- return *this;
- }
-
- bloom_filter & swap(bloom_filter & other) {
- using std::swap;
- swap(bit_set, other.bit_set);
- swap(hash_array, other.hash_array);
- return *this;
- }
-
- void insert(const_ref input) {
- for(size_t k = 0; k < K; ++k)
- bit_set[hash_array[k](input)] = 1;
- }
-
- bool contains(const_ref input) const {
- bool result = true;
- for(size_t k = 0; k < K && result; ++k)
- result = result && bit_set[hash_array[k](input)];
- return result;
- }
-
- bool operator[](const_ref input) const {
- return contains(input);
- }
-
- bloom_filter & clear() {
- bit_set.reset();
- return *this;
- }
-
- bitset_type const & state() const {
- return bit_set;
- }
-
- bool operator== (bloom_filter const & other) const {
- // FIXME For some reason, we cannot compare boost::function instances...
- // return (hash_array == other.hash_array) && (bit_set == other.bit_set);
- return bit_set == other.bit_set;
- }
-
- bool operator!= (bloom_filter const & other) const {
- return !(*this == other);
- }
- };
-
- template <class Input, size_t M, size_t K>
- inline void swap(
- bloom_filter<Input, M, K> & left,
- bloom_filter<Input, M, K> & right) {
- left.swap(right);
- }
-}
-
-#endif
-

Copied: sandbox/bloom_filter/trunk/boost/bloom_filter/static_bloom_filter.hpp (from r53780, /sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp (original)
+++ sandbox/bloom_filter/trunk/boost/bloom_filter/static_bloom_filter.hpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -17,7 +17,7 @@
 namespace boost {
 
     template <class Input, size_t M, size_t K>
- struct bloom_filter {
+ struct static_bloom_filter {
         public:
             typedef std::bitset<M> bitset_type;
 
@@ -32,27 +32,27 @@
             static size_t const functions = K;
             typedef Input element_type;
 
- explicit bloom_filter(
+ explicit static_bloom_filter(
                     array<function<size_t(Input)>, K> const & hash_functions
                     ) :
                 hash_array(hash_functions) {}
 
- bloom_filter(bitset_type const & initial_state = bitset_type())
+ static_bloom_filter(bitset_type const & initial_state = bitset_type())
                 : bit_set(initial_state)
             {
                 for(size_t k = 0; k < K; ++k)
                     hash_array[k] = detail::default_hash<Input,M>(k);
             }
 
- bloom_filter(bloom_filter const & other) :
+ static_bloom_filter(static_bloom_filter const & other) :
                 bit_set(other.bit_set), hash_array(other.hash_array) {}
 
- bloom_filter & operator=(bloom_filter rhs) {
+ static_bloom_filter & operator=(static_bloom_filter rhs) {
                 rhs.swap(*this);
                 return *this;
             }
 
- bloom_filter & swap(bloom_filter & other) {
+ static_bloom_filter & swap(static_bloom_filter & other) {
                 using std::swap;
                 swap(bit_set, other.bit_set);
                 swap(hash_array, other.hash_array);
@@ -75,7 +75,7 @@
                 return contains(input);
             }
 
- bloom_filter & clear() {
+ static_bloom_filter & clear() {
                 bit_set.reset();
                 return *this;
             }
@@ -84,21 +84,21 @@
                 return bit_set;
             }
 
- bool operator== (bloom_filter const & other) const {
+ bool operator== (static_bloom_filter const & other) const {
                 // FIXME For some reason, we cannot compare boost::function instances...
                 // return (hash_array == other.hash_array) && (bit_set == other.bit_set);
                 return bit_set == other.bit_set;
             }
 
- bool operator!= (bloom_filter const & other) const {
+ bool operator!= (static_bloom_filter const & other) const {
                 return !(*this == other);
             }
     };
 
     template <class Input, size_t M, size_t K>
         inline void swap(
- bloom_filter<Input, M, K> & left,
- bloom_filter<Input, M, K> & right) {
+ static_bloom_filter<Input, M, K> & left,
+ static_bloom_filter<Input, M, K> & right) {
             left.swap(right);
         }
 }

Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -4,11 +4,11 @@
 {
     test-suite "bloom_filter"
     :
- [ run bloom_filter_test.cpp ]
- [ run default_constructed_filter_test.cpp ]
- [ run bloom_filter_swap_adl_test.cpp ]
- [ run bloom_filter_equality_test.cpp ]
- [ run construct_from_bitset_test.cpp ]
+ [ run static_bloom_filter_test.cpp ]
+ [ run static_bloom_filter_default_construct_test.cpp ]
+ [ run static_bloom_filter_swap_adl_test.cpp ]
+ [ run static_bloom_filter_equality_test.cpp ]
+ [ run static_bloom_filter_construct_from_bitset_test.cpp ]
     ;
 }
 

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,20 +0,0 @@
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/bloom_filter.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-using boost::bloom_filter;
-
-int main(int argc, char * arg[]) {
- bloom_filter<int, 32, 3> filter1, filter2;
- assert(filter1 == filter2);
- filter1.insert(1);
- assert(filter1 != filter2);
- filter2.insert(1);
- assert(filter1 == filter2);
- return EXIT_SUCCESS;
-}
-

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,26 +0,0 @@
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/bloom_filter.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-using boost::bloom_filter;
-
-int main(int argc, char * argv[]) {
- typedef bloom_filter<uint32_t, 32, 3> filter_type;
- filter_type filter1, filter2;
- filter1.insert(1u);
- filter2.insert(2u);
- assert(!filter1.contains(2u));
- assert(filter1.contains(1u));
- assert(!filter2.contains(1u));
- assert(filter2.contains(2u));
- swap(filter1, filter2);
- assert(filter1.contains(2u));
- assert(!filter1.contains(1u));
- assert(filter2.contains(1u));
- assert(!filter2.contains(2u));
- return EXIT_SUCCESS;
-}

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,46 +0,0 @@
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/bloom_filter.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#define FILTER_SIZE 256
-
-size_t hash1(uint32_t id) {
- return ((id << 4) | (id >> 4)) % FILTER_SIZE;
-}
-
-size_t hash2(uint32_t id) {
- return (id * id) % FILTER_SIZE;
-}
-
-size_t hash3(uint32_t id) {
- return (id * 97) % FILTER_SIZE;
-}
-
-using std::bitset;
-using std::cout;
-using std::endl;
-using boost::array;
-using boost::function;
-using boost::bloom_filter;
-
-int main(int argc, char * argv[]) {
- array<function<size_t(uint32_t)>, 3> functions;
- functions[0] = hash1;
- functions[1] = hash2;
- functions[2] = hash3;
- typedef bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
- filter_type filter(functions);
- filter_type filter_copy = filter;
- for(uint32_t i = 0; i < 10; ++i) filter.insert(i);
- for(uint32_t i = 0; i < 10; ++i) assert(filter.contains(i));
- filter_type::bitset_type bit_set = filter.state();
- cout << endl;
- // assignment test
- filter_copy = filter;
- return EXIT_SUCCESS;
-}
-

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,18 +0,0 @@
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/bloom_filter.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-using boost::bloom_filter;
-
-int main(int argc, char * argv[]) {
- bloom_filter<int, 32, 3> filter1;
- filter1.insert(1);
- bloom_filter<int, 32, 3> filter2(filter1.state()); // construct from bitset
- assert(filter2.contains(1));
- return EXIT_SUCCESS;
-}
-

Deleted: sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
+++ (empty file)
@@ -1,20 +0,0 @@
-// Copyright 2009 (c) Dean Michael Berris <mikhailberis_at_[hidden]>
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/bloom_filter/bloom_filter.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#define FILTER_SIZE 256
-
-using boost::bloom_filter;
-
-int main(int argc, char * argv[]) {
- typedef bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
- filter_type filter; // default constructed
- filter.insert(1u);
- assert(filter.contains(1u));
- return EXIT_SUCCESS;
-}
-

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_construct_from_bitset_test.cpp (from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_construct_from_bitset_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -6,12 +6,12 @@
 #include <boost/bloom_filter.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-using boost::bloom_filter;
+using boost::static_bloom_filter;
 
 int main(int argc, char * argv[]) {
- bloom_filter<int, 32, 3> filter1;
+ static_bloom_filter<int, 32, 3> filter1;
     filter1.insert(1);
- bloom_filter<int, 32, 3> filter2(filter1.state()); // construct from bitset
+ static_bloom_filter<int, 32, 3> filter2(filter1.state()); // construct from bitset
     assert(filter2.contains(1));
     return EXIT_SUCCESS;
 }

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_default_construct_test.cpp (from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/default_constructed_filter_test.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_default_construct_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -3,15 +3,15 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/bloom_filter/bloom_filter.hpp>
+#include <boost/bloom_filter/static_bloom_filter.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
 #define FILTER_SIZE 256
 
-using boost::bloom_filter;
+using boost::static_bloom_filter;
 
 int main(int argc, char * argv[]) {
- typedef bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
+ typedef static_bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
     filter_type filter; // default constructed
     filter.insert(1u);
     assert(filter.contains(1u));

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_equality_test.cpp (from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_equality_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -6,10 +6,10 @@
 #include <boost/bloom_filter.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-using boost::bloom_filter;
+using boost::static_bloom_filter;
 
 int main(int argc, char * arg[]) {
- bloom_filter<int, 32, 3> filter1, filter2;
+ static_bloom_filter<int, 32, 3> filter1, filter2;
     assert(filter1 == filter2);
     filter1.insert(1);
     assert(filter1 != filter2);

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_swap_adl_test.cpp (from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_swap_adl_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -6,10 +6,10 @@
 #include <boost/bloom_filter.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
-using boost::bloom_filter;
+using boost::static_bloom_filter;
 
 int main(int argc, char * argv[]) {
- typedef bloom_filter<uint32_t, 32, 3> filter_type;
+ typedef static_bloom_filter<uint32_t, 32, 3> filter_type;
     filter_type filter1, filter2;
     filter1.insert(1u);
     filter2.insert(2u);

Copied: sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_test.cpp (from r53780, /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp)
==============================================================================
--- /sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_test.cpp (original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/static_bloom_filter_test.cpp 2009-06-10 00:40:24 EDT (Wed, 10 Jun 2009)
@@ -25,14 +25,14 @@
 using std::endl;
 using boost::array;
 using boost::function;
-using boost::bloom_filter;
+using boost::static_bloom_filter;
 
 int main(int argc, char * argv[]) {
     array<function<size_t(uint32_t)>, 3> functions;
     functions[0] = hash1;
     functions[1] = hash2;
     functions[2] = hash3;
- typedef bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
+ typedef static_bloom_filter<uint32_t, FILTER_SIZE, 3> filter_type;
     filter_type filter(functions);
     filter_type filter_copy = filter;
     for(uint32_t i = 0; i < 10; ++i) filter.insert(i);


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