Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72728 - sandbox/bloom_filter/trunk/boost/bloom_filter
From: cpp.cabrera_at_[hidden]
Date: 2011-06-24 04:27:16


Author: alejandro
Date: 2011-06-24 04:27:14 EDT (Fri, 24 Jun 2011)
New Revision: 72728
URL: http://svn.boost.org/trac/boost/changeset/72728

Log:
Added range and initializer list constructor. Added range insert.
Text files modified:
   sandbox/bloom_filter/trunk/boost/bloom_filter/bloom.hpp | 39 ++++++++++++++++++++++++++++++++++-----
   1 files changed, 34 insertions(+), 5 deletions(-)

Modified: sandbox/bloom_filter/trunk/boost/bloom_filter/bloom.hpp
==============================================================================
--- sandbox/bloom_filter/trunk/boost/bloom_filter/bloom.hpp (original)
+++ sandbox/bloom_filter/trunk/boost/bloom_filter/bloom.hpp 2011-06-24 04:27:14 EDT (Fri, 24 Jun 2011)
@@ -27,12 +27,15 @@
 #include <boost/bloom_filter/detail/apply_hash.hpp>
 #include <boost/bloom_filter/hash/default.hpp>
 
+#ifndef BOOST_NO_0X_HDR_INITIALIZER_LIST
+#include <initializer_list>
+#endif
+
 namespace boost {
   namespace bloom_filter {
     template <typename T,
               size_t Size,
- class HashFunctions = mpl::vector<boost_hash<T, 3>,
- boost_hash<T, 37> > >
+ class HashFunctions = mpl::vector<boost_hash<T, 3> > >
     class bloom_filter {
     public:
       typedef T value_type;
@@ -41,11 +44,26 @@
     public:
       bloom_filter() {}
 
- static BOOST_CONSTEXPR size_t size() const {
+ template <typename InputIterator>
+ bloom_filter (const InputIterator start, const InputIterator end) {
+ for (InputIterator i = start; i != end; ++i)
+ this->insert(*i);
+ }
+
+#ifndef BOOST_NO_0X_HDR_INITIALIZER_LIST
+ bloom_filter (std::initializer_list<T> ilist) {
+ typedef std::initializer_list::const_iterator citer;
+ for (citer i = ilist.begin(), end = ilist.end(); i != end; ++i) {
+ this->insert(*i);
+ }
+ }
+#endif
+
+ static BOOST_CONSTEXPR size_t bit_capacity() {
         return Size;
       }
 
- static BOOST_CONSTEXPR size_t num_hash_functions() const {
+ static BOOST_CONSTEXPR size_t num_hash_functions() {
         return mpl::size<HashFunctions>::value;
       };
 
@@ -62,12 +80,23 @@
         return this->bits.count();
       };
 
+ bool empty() const {
+ return this->count() == 0;
+ }
+
       void insert(const T& t) {
         static const unsigned N = mpl::size<HashFunctions>::value - 1;
         detail::apply_hash<N, T, Size, HashFunctions>::insert(t, bits);
       }
 
- bool contains(const T& t) const {
+ template <typename InputIterator>
+ void insert(const InputIterator start, const InputIterator end) {
+ for (InputIterator i = start; i != end; ++i) {
+ this->insert(*i);
+ }
+ }
+
+ bool probably_contains(const T& t) const {
         static const unsigned N = mpl::size<HashFunctions>::value - 1;
         return detail::apply_hash<N, T, Size, HashFunctions>::contains(t, bits);
       }


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