$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r53785 - in sandbox/bloom_filter/trunk: boost/bloom_filter libs/bloom_filter/test
From: mikhailberis_at_[hidden]
Date: 2009-06-10 04:59:40
Author: mikhailberis
Date: 2009-06-10 04:59:38 EDT (Wed, 10 Jun 2009)
New Revision: 53785
URL: http://svn.boost.org/trac/boost/changeset/53785
Log:
Adding tests and implementations for swapping and equality-comparing bloom_filters.
Added:
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp   (contents, props changed)
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp   (contents, props changed)
Text files modified: 
   sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp |    33 ++++++++++++++++++++++++++++++++-       
   sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2   |     2 ++                                      
   2 files changed, 34 insertions(+), 1 deletions(-)
Modified: 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/bloom_filter.hpp	2009-06-10 04:59:38 EDT (Wed, 10 Jun 2009)
@@ -44,7 +44,22 @@
                         size_t size, 
                         Sequence const & functions = Sequence())
                     : bit_set(size, 0), hash_functions(functions)
-                { }
+                {}
+
+                bloom_filter(bloom_filter const & other)
+                    : bit_set(other.bit_set), hash_functions(other.hash_functions)
+                {}
+
+                bloom_filter & operator= (bloom_filter rhs) {
+                    return rhs.swap(*this);
+                }
+
+                bloom_filter & swap(bloom_filter & other) {
+                    using std::swap;
+                    swap(bit_set, other.bit_set);
+                    swap(hash_functions, other.hash_functions);
+                    return *this;
+                }
 
                 void insert(const_ref input) {
                     using fusion::for_each;
@@ -65,8 +80,24 @@
                             );
                     return found;
                 }
+
+                bool operator==(bloom_filter const & other) const {
+                    return bit_set == other.bit_set;
+                }
+
+                bool operator!=(bloom_filter const & other) const {
+                    return !(*this == other);
+                }
         };
 
+    template <class Input, class Sequence, class Block, class Allocator>
+        inline void swap(
+                bloom_filter<Input, Sequence, Block, Allocator> & left,
+                bloom_filter<Input, Sequence, Block, Allocator> & right
+                ) {
+            left.swap(right);
+        }
+
 } // namespace boost
 
 #endif
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 04:59:38 EDT (Wed, 10 Jun 2009)
@@ -10,6 +10,8 @@
     [ run static_bloom_filter_equality_test.cpp ]
     [ run static_bloom_filter_construct_from_bitset_test.cpp ]
     [ run bloom_filter_construct_runtime_size_test.cpp ]
+    [ run bloom_filter_equality_test.cpp ]
+    [ run bloom_filter_swap_adl_test.cpp ]
     ;
 }
 
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_equality_test.cpp	2009-06-10 04:59:38 EDT (Wed, 10 Jun 2009)
@@ -0,0 +1,20 @@
+// 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> filter1(256), filter2(256);
+    assert(filter1 == filter2);
+    filter1.insert(1);
+    assert(filter1 != filter2);
+    filter2.insert(1);
+    assert(filter1 == filter2);
+    return EXIT_SUCCESS;
+}
+
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/bloom_filter_swap_adl_test.cpp	2009-06-10 04:59:38 EDT (Wed, 10 Jun 2009)
@@ -0,0 +1,28 @@
+// 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<int> filter_type;
+    filter_type filter(256);
+    filter_type filter_copy = filter;
+    assert(filter == filter_copy);
+    filter_type other_filter(1024);
+    assert(filter != other_filter);
+    assert(filter_copy != other_filter);
+    // assignment test
+    filter_copy = other_filter;
+    assert(filter_copy == other_filter);
+    assert(filter_copy != filter);
+    // swap test
+    swap(filter, other_filter);
+    assert(filter_copy != other_filter);
+    assert(filter_copy == filter);
+}
+