|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53772 - in sandbox/bloom_filter/trunk: boost/bloom_filter libs/bloom_filter/test
From: mikhailberis_at_[hidden]
Date: 2009-06-09 04:37:48
Author: mikhailberis
Date: 2009-06-09 04:37:47 EDT (Tue, 09 Jun 2009)
New Revision: 53772
URL: http://svn.boost.org/trac/boost/changeset/53772
Log:
Adding support for setting the intial state of the bloom filter using a bitset at construction time.
Added:
sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp (contents, props changed)
Text files modified:
sandbox/bloom_filter/trunk/boost/bloom_filter/bloom_filter.hpp | 4 +++-
sandbox/bloom_filter/trunk/libs/bloom_filter/test/Jamfile.v2 | 1 +
2 files changed, 4 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-09 04:37:47 EDT (Tue, 09 Jun 2009)
@@ -37,7 +37,9 @@
) :
hash_array(hash_functions) {}
- bloom_filter() {
+ 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);
}
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-09 04:37:47 EDT (Tue, 09 Jun 2009)
@@ -8,6 +8,7 @@
[ 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 ]
;
}
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/test/construct_from_bitset_test.cpp 2009-06-09 04:37:47 EDT (Tue, 09 Jun 2009)
@@ -0,0 +1,18 @@
+// 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;
+}
+
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